From 661563a2b6a0fe9bf8689170b81b54e95b129087 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 19 Sep 2023 12:14:55 +0200 Subject: [PATCH 1/3] refs #6210 Refactor filter client (zoneFk) --- modules/client/back/methods/client/filter.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/modules/client/back/methods/client/filter.js b/modules/client/back/methods/client/filter.js index 3bf29501b7..d7d1450abc 100644 --- a/modules/client/back/methods/client/filter.js +++ b/modules/client/back/methods/client/filter.js @@ -80,10 +80,15 @@ module.exports = Self => { Object.assign(myOptions, options); if (args.zoneFk) { - query = `CALL vn.zone_getPostalCode(?)`; - const [geos] = await Self.rawSql(query, [args.zoneFk]); - for (let geo of geos) - postalCode.push(geo.name); + let stmts = []; + stmts.push(new ParameterizedSQL('CALL vn.zone_getPostalCode(?)', [ args.zoneFk])); + stmts.push(`SELECT name FROM tmp.zoneNodes`); + stmts.push(`DROP TEMPORARY TABLE IF EXISTS tmp.zoneNodes`); + const sql = ParameterizedSQL.join(stmts, ';'); + const [results] = await conn.executeStmt(sql); + + for (let result of results) + postalCode.push(result.name); } const where = buildFilter(ctx.args, (param, value) => { -- 2.40.1 From 77b55e5b0947cd14d855326ba12a6260bbd671a5 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 19 Sep 2023 12:15:23 +0200 Subject: [PATCH 2/3] refs #6210 Minor change --- modules/client/back/methods/client/filter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/client/back/methods/client/filter.js b/modules/client/back/methods/client/filter.js index d7d1450abc..c109ea5b72 100644 --- a/modules/client/back/methods/client/filter.js +++ b/modules/client/back/methods/client/filter.js @@ -81,7 +81,7 @@ module.exports = Self => { if (args.zoneFk) { let stmts = []; - stmts.push(new ParameterizedSQL('CALL vn.zone_getPostalCode(?)', [ args.zoneFk])); + stmts.push(new ParameterizedSQL('CALL vn.zone_getPostalCode(?)', [args.zoneFk])); stmts.push(`SELECT name FROM tmp.zoneNodes`); stmts.push(`DROP TEMPORARY TABLE IF EXISTS tmp.zoneNodes`); const sql = ParameterizedSQL.join(stmts, ';'); -- 2.40.1 From 2686fd0601aca0b92d6635c355005c0836d938bd Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 19 Sep 2023 12:18:46 +0200 Subject: [PATCH 3/3] refs #6210 Minor change --- modules/client/back/methods/client/filter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/client/back/methods/client/filter.js b/modules/client/back/methods/client/filter.js index c109ea5b72..eaf4ecf308 100644 --- a/modules/client/back/methods/client/filter.js +++ b/modules/client/back/methods/client/filter.js @@ -83,7 +83,7 @@ module.exports = Self => { let stmts = []; stmts.push(new ParameterizedSQL('CALL vn.zone_getPostalCode(?)', [args.zoneFk])); stmts.push(`SELECT name FROM tmp.zoneNodes`); - stmts.push(`DROP TEMPORARY TABLE IF EXISTS tmp.zoneNodes`); + stmts.push(`DROP TEMPORARY TABLE tmp.zoneNodes`); const sql = ParameterizedSQL.join(stmts, ';'); const [results] = await conn.executeStmt(sql); -- 2.40.1