From 3d9a3d48df3071675f11443f36b00db149e21170 Mon Sep 17 00:00:00 2001 From: joschne Date: Wed, 14 Aug 2019 10:06:56 +0200 Subject: [PATCH] fixed creation of where clause in translateJoin When closing joins after a certain level of depth (3rd level), the wrong where clause was used to close the join. This commit tries to fix that. --- findComplex.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/findComplex.js b/findComplex.js index b00fa43..d30d06b 100644 --- a/findComplex.js +++ b/findComplex.js @@ -486,12 +486,14 @@ findComplex.prototype.translateJoin = function(join,method='LATERAL',parentJoin, +tmpParentJoin.alias+"."+tmpJoin.relationData.keyFrom; } - if(closeJoin.where != null){ + // TODO: The following parentJoin.where replaces former closeJoin.where. Check if works correctly. + if(parentJoin.where != null){ mainQuery.sql = mainQuery.sql + " AND "; - mainQuery = mainQuery.merge(closeJoin.where,""); + mainQuery = mainQuery.merge(parentJoin.where,""); } } else{ + // TODO: Check if the following closeJoin.where should also be changed to parentJoin.where. if(closeJoin.where != null){ mainQuery.sql = mainQuery.sql + " WHERE "; mainQuery = mainQuery.merge(closeJoin.where,"");