Remove nested parentheses for checks

This commit is contained in:
1ilit 2024-04-24 18:28:28 +03:00
parent a88bc9799f
commit a2c5b8156f

View File

@ -9,7 +9,7 @@ function buildSQLFromAST(ast) {
if (ast.type === "binary_expr") { if (ast.type === "binary_expr") {
const leftSQL = buildSQLFromAST(ast.left); const leftSQL = buildSQLFromAST(ast.left);
const rightSQL = buildSQLFromAST(ast.right); const rightSQL = buildSQLFromAST(ast.right);
return `(${leftSQL}) ${ast.operator} (${rightSQL})`; return `${leftSQL} ${ast.operator} ${rightSQL}`;
} }
if (ast.type === "function") { if (ast.type === "function") {
@ -37,7 +37,7 @@ function buildSQLFromAST(ast) {
} else if (ast.type === "expr_list") { } else if (ast.type === "expr_list") {
return ast.value.map((v) => v.value).join(" AND "); return ast.value.map((v) => v.value).join(" AND ");
} else { } else {
return ast.value; return typeof ast.value === "string" ? "'" + ast.value + "'" : ast.value;
} }
} }