Have left and right both be binary expressions, or
Have left and right both be other types of expressions.
The typechecker fails for ASTs produced from SQL statements that use a binary expression where either left or right is a binary expression, but not both.
Database Engine
PostgreSQL
To Reproduce
In node-sql-parser@5.3.2, run:
const parser = new SQLParser();
const ast = parser.astify(`SELECT * FROM "table" WHERE ("year" || "month") = '202301'`);
Describe the bug The type definition for binary expressions requires that a binary expression either:
left
andright
both be binary expressions, orleft
andright
both be other types of expressions.The typechecker fails for ASTs produced from SQL statements that use a binary expression where either
left
orright
is a binary expression, but not both.Database Engine PostgreSQL
To Reproduce In node-sql-parser@5.3.2, run:
The value of
ast.where
is:Yet setting
ast.where
to this value throws a type error.Expected behavior
Any value emitted by
astify
should satisfy the TypeScript types.