Skip to content

Commit

Permalink
Fix free objects being materialized as if they are volatile. (#8000)
Browse files Browse the repository at this point in the history
  • Loading branch information
dnwpark authored Nov 16, 2024
1 parent 2484dcb commit bd2cb47
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 18 deletions.
3 changes: 0 additions & 3 deletions edb/edgeql/compiler/setgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -1959,9 +1959,6 @@ def should_materialize(
if not isinstance(ir, irast.Set):
return reasons

if irtyputils.is_free_object(ir.typeref):
reasons.append(irast.MaterializeVolatile())

typ = get_set_type(ir, ctx=ctx)

assert ir.path_scope_id is not None
Expand Down
18 changes: 3 additions & 15 deletions tests/test_edgeql_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -1499,14 +1499,7 @@ async def test_edgeql_group_destruct_immediately_02(self):
["element", "element", "element", "element"],
)

@test.xerror("""
Issue #5796
Materialized set not finalized.
""")
async def test_edgeql_group_issue_5796(self):
# Fails on assert mat_set.materialized .
# Depends on double select and deck in shape
await self.assert_query_result(
r'''
with
Expand All @@ -1528,7 +1521,6 @@ async def test_edgeql_group_issue_5796(self):
]),
)

@test.xerror("Issue #6059")
async def test_edgeql_group_issue_6059(self):
await self.assert_query_result(
r'''
Expand All @@ -1547,7 +1539,6 @@ async def test_edgeql_group_issue_6059(self):
[{"keyCard": {}}] * 4,
)

@test.xerror("Issue #6060")
async def test_edgeql_group_issue_6060(self):
await self.assert_query_result(
r'''
Expand Down Expand Up @@ -1609,13 +1600,10 @@ async def test_edgeql_group_issue_6019_a(self):
) by .key
''')

@test.xerror("""
Issue #6019
Grouping on key should probably be rejected.
(And if not, it should not ISE!)
""")
async def test_edgeql_group_issue_6019_b(self):
# This didn't work because group created free objects which were then
# materialized as volatile. `group (group X by .x) by .key` has a
# different cause.
await self.assert_query_result(
'''
with
Expand Down
26 changes: 26 additions & 0 deletions tests/test_edgeql_insert.py
Original file line number Diff line number Diff line change
Expand Up @@ -6814,6 +6814,32 @@ async def test_edgeql_insert_volatile_42(self):
[1],
)

async def test_edgeql_insert_with_freeobject_01(self):
await self.con.execute('''
WITH free := { name := "asdf" },
SELECT (INSERT Person { name := free.name });
''')

await self.assert_query_result(
'SELECT Person.name = "asdf"',
[True],
)

async def test_edgeql_insert_with_freeobject_02(self):
await self.con.execute('''
WITH free := { name := <str>random() },
SELECT (INSERT Person { name := free.name, tag := free.name });
''')

await self.assert_query_result(
'WITH P := (Person {ok := .name = .tag}) SELECT all(P.ok)',
[True],
)
await self.assert_query_result(
'SELECT count(distinct(Person.name))',
[1],
)

async def test_edgeql_insert_multi_exclusive_01(self):
await self.con.execute('''
INSERT Person { name := "asdf", multi_prop := "a" };
Expand Down

0 comments on commit bd2cb47

Please sign in to comment.