From 8270458e9656478e6c5ae0286664e5ad0b953b5d Mon Sep 17 00:00:00 2001
From: Johannes Hoermann <j.hoermann@adito.de>
Date: Mon, 18 Nov 2019 16:41:19 +0100
Subject: [PATCH] add pForceAsStatement in toString of sqlBuilder

---
 process/Sql_lib/process.js | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/process/Sql_lib/process.js b/process/Sql_lib/process.js
index 1a55a386f9..740c601d92 100644
--- a/process/Sql_lib/process.js
+++ b/process/Sql_lib/process.js
@@ -956,15 +956,17 @@ SqlBuilder.begin = function ()
 
 /**
  * Builds the sql and uses SqlUtils.translateXXXWithQuotes to make a string out of it.
+ * @param {String} [pDefaultConditionIfNone=""] the default condition string to use if the SqlBuilder contains no condition. In most cases you won't need this
+ * @param {Boolean} [pForceAsStatement=false] forces the use of SqlUtils.translateStatementWithQuotes even if it's no full statement. This is needed for example if you do not want brakets around the generated statement
  * @return {String} the sql as string
  */
-SqlBuilder.prototype.toString = function(pDefaultConditionIfNone)
+SqlBuilder.prototype.toString = function(pDefaultConditionIfNone, pForceAsStatement)
 {
     var built = this.build(pDefaultConditionIfNone)
     
     if (built[0] !== "")
     {
-        if (!this.isFullSelect() && (this.hasCondition() || pDefaultConditionIfNone))
+        if (!pForceAsStatement && !this.isFullSelect() && (this.hasCondition() || pDefaultConditionIfNone))
             return SqlUtils.translateConditionWithQuotes(built, this.alias);
         else
             return SqlUtils.translateStatementWithQuotes(built, this.alias);
-- 
GitLab