Bug Description
Round-trip rendering drops the NOT qualifier: a query WHERE email IS NOT NULL
is re-emitted as WHERE email IS NULL.
Root cause
pkg/sql/parser/expressions_operators.go stores IS NOT NULL as
BinaryExpression{Operator: "IS NULL", Not: true}. BinaryExpression.SQL()
(pkg/sql/ast/sql.go) renders the operator string verbatim and ignores the
Not flag in the null branch, silently inverting the predicate.
To Reproduce
tree, _ := gosqlx.Parse("SELECT * FROM users WHERE email IS NOT NULL")
fmt.Println(tree.SQL())
// SELECT * FROM users WHERE email IS NULL (NOT lost!)
Expected Behavior
SELECT * FROM users WHERE email IS NOT NULL
Notes
Exists in v1.14.0 and current main (31b5b1c). Affects both PostgreSQL and
ClickHouse dialects. PR: #529.
Bug Description
Round-trip rendering drops the
NOTqualifier: a queryWHERE email IS NOT NULLis re-emitted as
WHERE email IS NULL.Root cause
pkg/sql/parser/expressions_operators.gostoresIS NOT NULLasBinaryExpression{Operator: "IS NULL", Not: true}.BinaryExpression.SQL()(
pkg/sql/ast/sql.go) renders the operator string verbatim and ignores theNotflag in the null branch, silently inverting the predicate.To Reproduce
Expected Behavior
SELECT * FROM users WHERE email IS NOT NULLNotes
Exists in v1.14.0 and current
main(31b5b1c). Affects both PostgreSQL andClickHouse dialects. PR: #529.