From 28d43a38c6c2c8a2a34852da15c575b4574af274 Mon Sep 17 00:00:00 2001 From: "j.goderbauer" <j.goderbauer@adito.de> Date: Thu, 27 Aug 2020 15:54:35 +0200 Subject: [PATCH] Sql_lib: SqlBuilder accepts conditions constants like: SqlBuilder.EQUAL (the whole function) --- .../recordcontainers/db/conditionProcess.js | 2 +- process/Sql_lib/process.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/entity/ActivityLink_entity/recordcontainers/db/conditionProcess.js b/entity/ActivityLink_entity/recordcontainers/db/conditionProcess.js index 174ad7f6d1..5cb1b40d4c 100644 --- a/entity/ActivityLink_entity/recordcontainers/db/conditionProcess.js +++ b/entity/ActivityLink_entity/recordcontainers/db/conditionProcess.js @@ -3,7 +3,7 @@ import("system.db"); import("system.result"); import("Sql_lib"); -var cond = newWhereIfSet("ACTIVITYLINK.ACTIVITY_ID", "$param.ActivityId_param"); +var cond = newWhereIfSet("ACTIVITYLINK.ACTIVITY_ID", "$param.ActivityId_param", SqlBuilder.EQUAL); //TODO: use a preparedCondition (.build instead of .toString) when available #1030812 #1034026 result.string(cond.toString()); \ No newline at end of file diff --git a/process/Sql_lib/process.js b/process/Sql_lib/process.js index 16f855efb7..b998ddb47f 100644 --- a/process/Sql_lib/process.js +++ b/process/Sql_lib/process.js @@ -1445,6 +1445,8 @@ SqlBuilder.prototype._addWhere = function(pFieldOrCond, pValue, pMandatory, pCon { //In a special case, pCondition can be a function. It will be called with the alias as argument and //must return an array of the condition string and (optionally) the required sql field type. + //alternatively the function may return a string only to make the usage more bulletproof and convenient, so both SqlBuilder.EQUAL() + //and SqlBuilder.EQUAL work equally if (pCondition && typeof pCondition === "function") { var resCond = pCondition(this.alias); @@ -1453,6 +1455,10 @@ SqlBuilder.prototype._addWhere = function(pFieldOrCond, pValue, pMandatory, pCon pCondition = resCond[0]; pFieldType = pFieldType || resCond[1]; } + else if(typeof(resCond) == "string") + { + pCondition = resCond; + } } if (pCondition && !SqlUtils.checkConditionFormat(pCondition)) -- GitLab