Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix spurious delete/create of constraints with arguments in migrations #6704

Merged
merged 1 commit into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions edb/schema/reflection/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,13 @@ def _build_object_mutation_shape(
# an ObjectKeyDict collection that allow associating objects
# with arbitrary values (a transposed ObjectDict).
target_expr = f"""assert_distinct((
FOR v IN {{ json_array_unpack(<json>${var_n}) }}
FOR v IN {{ enumerate(json_array_unpack(<json>${var_n})) }}
UNION (
SELECT {target.get_name(schema)} {{
@value := <str>v[1]
@index := v.0,
@value := <str>v.1[1],
}}
FILTER .id = <uuid>v[0]
FILTER .id = <uuid>v.1[0]
)
))"""
args = props.get('args', [])
Expand Down
20 changes: 20 additions & 0 deletions tests/test_edgeql_ddl.py
Original file line number Diff line number Diff line change
Expand Up @@ -10190,6 +10190,26 @@ async def test_edgeql_ddl_constraint_09(self):
CREATE TYPE Comment EXTENDING Text;
""")

await self.assert_query_result(
"""
select schema::Constraint {
name, params: {name, @index} order by @index
}
filter .name = 'std::max_len_value'
and .subject.name = 'body'
and .subject[is schema::Pointer].source.name ='default::Text';
""",
[
{
"name": "std::max_len_value",
"params": [
{"name": "__subject__", "@index": 0},
{"name": "max", "@index": 1}
]
}
],
)

await self.con.execute("""
ALTER TYPE Text
ALTER PROPERTY body
Expand Down
Loading