diff --git a/src/syntax/expr.ts b/src/syntax/expr.ts index 7fc7c0f..a1670af 100644 --- a/src/syntax/expr.ts +++ b/src/syntax/expr.ts @@ -80,7 +80,9 @@ export const exprMap: CstToDocMap = { // For now this check here patches up the deficiency in the parser. !grandParent.distinctKw && !isSelectStmt(node.expr) && - !isCompoundSelectStmt(node.expr) + !isCompoundSelectStmt(node.expr) && + // (a, b) is a single row argument, not two arguments + !isListExpr(node.expr) ) { return print("expr"); } diff --git a/test/expr/expr.test.ts b/test/expr/expr.test.ts index 29679d1..f7f0db4 100644 --- a/test/expr/expr.test.ts +++ b/test/expr/expr.test.ts @@ -159,6 +159,12 @@ describe("expr", () => { `); }); + it(`preserves parenthesis around row constructor inside function arguments`, async () => { + await testPostgresql(dedent` + SELECT array_position(ids, (1, 1)) FROM tbl + `); + }); + describe("case", () => { it(`formats CASE expression always on multiple lines`, async () => { await test(dedent`