Skip to content

Commit

Permalink
[sql] Fix native SQL protocol on old postgres versions (#8268)
Browse files Browse the repository at this point in the history
I broke it in #8256 by adding a RangeSubselect without an alias.
  • Loading branch information
msullivan authored Jan 29, 2025
1 parent 67c2ac5 commit e2893a3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions edb/pgsql/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,11 @@ class WindowDef(ImmutableBase):
class RangeSubselect(PathRangeVar):
"""Subquery appearing in FROM clauses."""

# Before postgres 16, an alias is always required on selects from
# a subquery. Try to catch that with the typechecker by getting
# rid of the default value.
alias: Alias

lateral: bool = False
subquery: Query

Expand Down
5 changes: 4 additions & 1 deletion edb/pgsql/resolver/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,10 @@ def resolve(
val=expr.construct_row_expr(columns, ctx=ctx)
)
],
from_clause=[pgast.RangeSubselect(subquery=e)],
from_clause=[pgast.RangeSubselect(
subquery=e,
alias=pgast.Alias(aliasname='r'),
)],
ctes=e.ctes,
)
e.ctes = []
Expand Down

0 comments on commit e2893a3

Please sign in to comment.