From c0f6a28ae93134b8cddc8416887fbad34b2b86a1 Mon Sep 17 00:00:00 2001
From: Johannes Hoermann <j.hoermann@adito.de>
Date: Tue, 18 Dec 2018 09:52:21 +0100
Subject: [PATCH] easy sql-condition

---
 process/Sql_lib/process.js | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/process/Sql_lib/process.js b/process/Sql_lib/process.js
index 4a3240d2a2a..95fda3cf3d7 100644
--- a/process/Sql_lib/process.js
+++ b/process/Sql_lib/process.js
@@ -377,6 +377,35 @@ SqlCondition.prototype._init = function() {
     //init only wraps the clear function to avoid confusion in the constructor (and provide better extensibility)
     return this.clear();
 }
+
+// some static functions for often used tasks. They are only provided for very simple tasks.
+
+/**
+ * pField = pValue
+ * @param {String} pField the database field as "tablename.columnname"; e.g. "ORG.NAME"
+ * @param {String} pValue the value that shall be set into the prepared statement
+ * @param {String} [pAlternativeCond=""] Condition that is returned when nothing has been appended.
+ * @param {String} [pAlias=the current alias] the database alias where the condition shall be executed later (important for column types of preparedStatements)
+ * 
+ * @return {Array[][][]} Prepared condition with [condition, [[field, type]]]
+ */
+SqlCondition.equals = function(pField, pValue, pAlternativeCond, pAlias) {
+    return SqlCondition.begin(pAlias).andPrepare(pField, pValue).build(pAlternativeCond);
+}
+
+/**
+ * pField <> pValue
+ * @param {String} pField the database field as "tablename.columnname"; e.g. "ORG.NAME"
+ * @param {String} pValue the value that shall be set into the prepared statement
+ * @param {String} [pAlternativeCond=""] Condition that is returned when nothing has been appended.
+ * @param {String} [pAlias=the current alias] the database alias where the condition shall be executed later (important for column types of preparedStatements)
+ * 
+ * @return {Array[][][]} Prepared condition with [condition, [[field, type]]]
+ */
+SqlCondition.equalsNot = function(pField, pValue, pAlternativeCond, pAlias) {
+    return SqlCondition.begin(pAlias).andPrepare(pField, pValue, "# <> ?").build(pAlternativeCond);
+}
+
 /**
  provides functions for masking sql functions
 *
-- 
GitLab