Skip to content

Commit

Permalink
check function argument isn't a select statement
Browse files Browse the repository at this point in the history
  • Loading branch information
bparnell-4tel committed Aug 29, 2024
1 parent 626354c commit 26258e4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/node_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export const isStringLiteral = is("string_literal");
export const isArraySubscript = is("array_subscript");
export const isAsClause = is("as_clause");
export const isParenExpr = is("paren_expr");
export const isSelectStmt = is("select_stmt");
export const isCompoundSelectStmt = is("compound_select_stmt");
export const isListExpr = is("list_expr");
export const isCreateFunctionStmt = is("create_function_stmt");
export const isLanguageClause = is("language_clause");
Expand Down
6 changes: 5 additions & 1 deletion src/syntax/expr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import {
isFuncArgs,
isListExpr,
isProgram,
isSelectStmt,
isCompoundSelectStmt,
} from "../node_utils";
import { isString, last } from "../utils";

Expand Down Expand Up @@ -48,7 +50,9 @@ export const exprMap: CstToDocMap<AllExprNodes> = {
// Discard unnecessary parenthesis around function arguments
if (
isListExpr(path.getParentNode(0)) &&
isFuncArgs(path.getParentNode(1))
isFuncArgs(path.getParentNode(1)) &&
!isSelectStmt(node.expr) &&
!isCompoundSelectStmt(node.expr)
) {
return print("expr");
}
Expand Down

0 comments on commit 26258e4

Please sign in to comment.