diff --git a/modules/agency/back/methods/zone-geo/getLeaves.js b/modules/agency/back/methods/zone-geo/getLeaves.js index 451457916..bfcef08ae 100644 --- a/modules/agency/back/methods/zone-geo/getLeaves.js +++ b/modules/agency/back/methods/zone-geo/getLeaves.js @@ -88,7 +88,9 @@ module.exports = Self => { FROM zoneGeo zg LEFT JOIN zoneIncluded zi ON zi.geoFk = zg.id AND zi.zoneFk = ? - WHERE zg.parentFk IS NULL OR zg.parentFk = ?) 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));