From 661563a2b6a0fe9bf8689170b81b54e95b129087 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 19 Sep 2023 12:14:55 +0200 Subject: [PATCH] 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 3bf29501b..d7d1450ab 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) => {