diff --git a/src/expr.js b/src/expr.js index 74262878..ddd4c44d 100644 --- a/src/expr.js +++ b/src/expr.js @@ -82,6 +82,7 @@ function unaryToSQL(unarExpr) { function getExprListSQL(exprList) { if (!exprList) return [] + if (!Array.isArray(exprList)) exprList = [exprList] return exprList.map(exprToSQL) } diff --git a/test/postgres.spec.js b/test/postgres.spec.js index 3ff3779c..9fd00c45 100644 --- a/test/postgres.spec.js +++ b/test/postgres.spec.js @@ -1521,6 +1521,26 @@ describe('Postgres', () => { `CREATE TABLE "table_0" ("hi" INTEGER ARRAY) ; CREATE TABLE "table_1" ("hi" INTEGER[3])` ] }, + { + title: 'binary expr as fun args', + sql: [ + `SELECT + somefunc( + engineering_networks.realizaciya, + engineering_networks.company = 'blah-blah' + AND + engineering_networks.obem_realizacii_tip = 'uslugi' + ) AS var0, + If(var0 > 0, '2', '1') AS fontColor + FROM engineering_networks AS engineering_networks + WHERE + engineering_networks.company = 'blah-blah' AND + engineering_networks.month IN ('April') AND + engineering_networks.year IN ('2024') + LIMIT 1;`, + `SELECT somefunc("engineering_networks".realizaciya, "engineering_networks".company = 'blah-blah' AND "engineering_networks".obem_realizacii_tip = 'uslugi') AS "var0", If(var0 > 0, '2', '1') AS "fontColor" FROM "engineering_networks" AS "engineering_networks" WHERE "engineering_networks".company = 'blah-blah' AND "engineering_networks".month IN ('April') AND "engineering_networks".year IN ('2024') LIMIT 1` + ], + } ] function neatlyNestTestedSQL(sqlList){ sqlList.forEach(sqlInfo => {