From 0be700b65f7ca185b5b8800ebfcc04523dda86ad Mon Sep 17 00:00:00 2001
From: Johannes Hoermann <j.hoermann@adito.de>
Date: Thu, 17 Oct 2019 16:40:01 +0200
Subject: [PATCH] add warning for big in-statements

---
 process/Sql_lib/process.js | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/process/Sql_lib/process.js b/process/Sql_lib/process.js
index a4cf96d6be4..c9dcace5ec0 100644
--- a/process/Sql_lib/process.js
+++ b/process/Sql_lib/process.js
@@ -2462,6 +2462,10 @@ SqlUtils.getSystemAlias = function()
      */
 SqlUtils.getSqlInStatement = function(pFieldname, pData, pQuoteSymbol, pAsPrepared, pPreparedDbType) 
 {
+    var MAX_COUNT = 1000;
+    if (pData.length > 1000)
+        logging.log(translate.text("SqlUtils.getSqlInStatement: WARNING: You should not create in-statements with more than 1000 values. As this has a very bad performance."))
+    
     if (pData.length == 0)
         return " 1 = 2 ";
 
@@ -2476,7 +2480,6 @@ SqlUtils.getSqlInStatement = function(pFieldname, pData, pQuoteSymbol, pAsPrepar
             throw new Error(translate.text("SqlUtils.getSqlInStatement: if pAsPrepared is true, pPreparedDbType has to be filld with the correct db type"));
     }
 
-    var MAX_COUNT = 1000;
     //pData.length -1 um für den Fall, dass MAX_COUNT == pData.length ist trotzdem nur einen Aufruf
     //zu machen
     var count = ((pData.length -1) / MAX_COUNT) >> 0;//aus kommazahl eine ganzzahl machen
-- 
GitLab