You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
x = ANY(SELECT ...) <op> y: the operator after ) is parsed into the ANY/ALL operand #2802
PostgreSQL applies the operator to the comparison: SELECT pg_typeof(1 = ANY(SELECT 1)::text) returns text, and SELECT 2 = ANY(SELECT 1) + 1 fails with operator does not exist: boolean + integer (PostgreSQL 18). The docs say "The right-hand side is a parenthesized subquery": https://www.postgresql.org/docs/current/functions-subquery.html#FUNCTIONS-SUBQUERY-ANY-SOME
The Display side has the reverse problem: SELECT a = ANY((SELECT 1)) - 1 parses as (a = ANY(SELECT 1)) - 1 but displays as SELECT a = ANY(SELECT 1) - 1, which reparses as the first tree.
The subquery branch in parse_infix (from #1459) rewinds to the ( and calls parse_subexpr(precedence); Display for AnyOp/AllOp leaves out the parentheses when the right side is an Expr::Subquery.
Tested with PostgreSqlDialect on main ce12f1f (also 0.63.0 and 0.58.0).
Found with a property-based fuzzer (round trip check); I used AI assistance for triage and verified every case above.
Activity