From 043fe80254aff13f2ee3a8e6eba389c93aeb8497 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Fri, 13 Sep 2019 13:26:50 +0200 Subject: [PATCH] cherry 1 --- modules/agency/back/methods/zone-geo/getLeaves.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/agency/back/methods/zone-geo/getLeaves.js b/modules/agency/back/methods/zone-geo/getLeaves.js index 4f21aea41..f3ddc722e 100644 --- a/modules/agency/back/methods/zone-geo/getLeaves.js +++ b/modules/agency/back/methods/zone-geo/getLeaves.js @@ -92,7 +92,9 @@ module.exports = Self => { AND child.depth = parent.depth + 1 LEFT JOIN zoneIncluded zi ON zi.geoFk = child.id AND zi.zoneFk = ? - WHERE parent.id = ?) AS nst`, [zoneFk, parentFk]); + WHERE (? IS NULL AND zg.parentFk IS NULL) + OR (? IS NOT NULL AND zg.parentFk = ?)) AS nst`, + [zoneFk, parentFk, parentFk, parentFk]); // Get nodes from depth greather than Origin stmt.merge(conn.makeSuffix(filter));