From 8497a70ae933950db98d21bf7d3157808904c6dc Mon Sep 17 00:00:00 2001
From: "S.Listl" <s.listl@adito.de>
Date: Thu, 28 Nov 2019 09:43:23 +0100
Subject: [PATCH] Sql_lib: .clearWhere completely resets the condition

---
 process/Sql_lib/process.js | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/process/Sql_lib/process.js b/process/Sql_lib/process.js
index 608c0c3bca2..52637d33d0a 100644
--- a/process/Sql_lib/process.js
+++ b/process/Sql_lib/process.js
@@ -790,18 +790,8 @@ function SqlBuilder (pAlias)
     
     this._subselectAlias = null;
     
-    this._where = {
-        preparedValues: [],
-        _sqlStorage: "",
-        
-        // save, if the last condition was an OR. For better bracket-placement
-        _lastWasOr: false,
-        // also for better bracket-placement
-        _previouslyOnlyOr: false,
-        
-        // where has always to be called first for a better semantic
-        _whereWasCalled: false
-    }
+    this._where = {};
+    this._initWhere();
 }
 
 /**
@@ -1995,10 +1985,22 @@ SqlBuilder.prototype.isFullSelect = function()
  * @return {SqlBuilder} current SqlBuilder object
  */
 SqlBuilder.prototype.clearWhere = function() 
+{
+    this._initWhere();
+    return this;
+}
+
+/**
+ * function that initializes the properties of the ._where object, this is used in the
+ * constructor and .clearWhere 
+ */
+SqlBuilder.prototype._initWhere = function ()
 {
     this._where._sqlStorage = "";
     this._where.preparedValues = [];
-    return this;
+    this._where._lastWasOr = false; // save, if the last condition was an OR. For better bracket-placement
+    this._where._previouslyOnlyOr = false; // also for better bracket-placement
+    this._where._whereWasCalled = false; // where has always to be called first for a better semantic
 }
 
 /**
-- 
GitLab