It took me a while to come up with this example, and it's not totally realistic, but it's probably still worth fixing. Basically, the precedence of NOT LIKE is mishandled, because the precedence of NOT is fixed to its unary operator precedence, when in it needs to vary based on whether the NOT keyword is followed by LIKE/BETWEEN/IN/.
Concretely, SELECT a LIKE b IS NULL parses correctly, with the LIKE binding more tightly than the IS NULL:
SQLIsNull(
SQLBinaryExpr {
left: SQLIdentifier(
"a"
),
op: Like,
right: SQLIdentifier(
"b"
)
}
)
But when NOT LIKE is substituted for LIKE, the IS NULL incorrectly binds more tightly than the NOT LIKE:
SQLBinaryExpr {
left: SQLIdentifier(
"a"
),
op: NotLike,
right: SQLIsNull(
SQLIdentifier(
"b"
)
)
}
It took me a while to come up with this example, and it's not totally realistic, but it's probably still worth fixing. Basically, the precedence of
NOT LIKEis mishandled, because the precedence ofNOTis fixed to its unary operator precedence, when in it needs to vary based on whether the NOT keyword is followed by LIKE/BETWEEN/IN/.Concretely,
SELECT a LIKE b IS NULLparses correctly, with the LIKE binding more tightly than the IS NULL:But when NOT LIKE is substituted for LIKE, the IS NULL incorrectly binds more tightly than the NOT LIKE: