Skip to content

Commit

Permalink
Fix UPDATE with rewrites on tuples (#6337)
Browse files Browse the repository at this point in the history
Closes #6291

We has `expr_exposed` set on ctx that was used to provide
the value for UPDATE expression.
This caused the value to be serialized.
  • Loading branch information
aljazerzen committed Oct 24, 2023
1 parent 4c7e6b5 commit a038c10
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions edb/pgsql/compiler/dml.py
Original file line number Diff line number Diff line change
Expand Up @@ -1984,6 +1984,7 @@ def process_update_shape(
and updvalue is not None
):
with ctx.newscope() as scopectx:
scopectx.expr_exposed = False
val: pgast.BaseExpr

if irtyputils.is_tuple(element.typeref):
Expand Down
25 changes: 25 additions & 0 deletions tests/test_edgeql_rewrites.py
Original file line number Diff line number Diff line change
Expand Up @@ -953,3 +953,28 @@ async def test_edgeql_rewrites_23(self):
'select Person { first_name }',
[{'first_name': 'updated'}],
)

async def test_edgeql_rewrites_24(self):
await self.con.execute(
'''
create type X {
create property tup -> tuple<int64, str> {
create rewrite insert, update using ((1, '2'));
};
};
insert X;
'''
)
await self.assert_query_result(
'select X { tup }',
[{'tup': (1, '2')}],
)
await self.con.execute(
'''
update X set {};
'''
)
await self.assert_query_result(
'select X { tup }',
[{'tup': (1, '2')}],
)

0 comments on commit a038c10

Please sign in to comment.