Skip to content

Commit

Permalink
fix: binary expr as fun args in pg
Browse files Browse the repository at this point in the history
  • Loading branch information
taozhi8833998 committed Jul 13, 2024
1 parent f7ba2b9 commit a11d9c6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/expr.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ function unaryToSQL(unarExpr) {

function getExprListSQL(exprList) {
if (!exprList) return []
if (!Array.isArray(exprList)) exprList = [exprList]
return exprList.map(exprToSQL)
}

Expand Down
20 changes: 20 additions & 0 deletions test/postgres.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down

0 comments on commit a11d9c6

Please sign in to comment.