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 counting references to properties #5450

Merged
merged 1 commit into from May 9, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 0 additions & 17 deletions edb/schema/links.py
Expand Up @@ -713,23 +713,6 @@ class DeleteLink(
astnode = [qlast.DropConcreteLink, qlast.DropLink]
referenced_astnode = qlast.DropConcreteLink

def _delete_begin(
self,
schema: s_schema.Schema,
context: sd.CommandContext,
) -> s_schema.Schema:
schema = super()._delete_begin(schema, context)
if not context.canonical:
# We need to do a propagate here, too, since there could
# be backrefs to this link that technically reference
# us but will be fine if it is deleted.
schema = self._propagate_if_expr_refs(
schema,
context,
action=self.get_friendly_description(schema=schema),
)
return schema

def _get_ast(
self,
schema: s_schema.Schema,
Expand Down
10 changes: 10 additions & 0 deletions edb/schema/pointers.py
Expand Up @@ -2219,6 +2219,16 @@ def _delete_begin(
):
self.add_caused(del_cmd)

if not context.canonical:
# We need to do a propagate here, too, since there could
# be backrefs to this pointer that technically reference
# us but will be fine if it is deleted.
schema = self._propagate_if_expr_refs(
schema,
context,
action=self.get_friendly_description(schema=schema),
)

return schema

def _canonicalize(
Expand Down
30 changes: 30 additions & 0 deletions tests/test_edgeql_data_migration.py
Expand Up @@ -11457,6 +11457,36 @@ async def test_edgeql_migration_backlink_overloaded(self):
}
''')

async def test_edgeql_migration_property_ref(self):
await self.migrate(r'''
type Log {
body: str;
timestamp: datetime {
default := datetime_current();
}
}

type Person {
required name: str;
trigger log_delete after insert for each do (
insert Log { body := __new__.name }
);
}
''')

await self.migrate(r'''
type Log {
body: str;
}

type Person {
required name: str;
trigger log_delete after insert for each do (
insert Log { body := __new__.name }
);
}
''')

async def test_edgeql_migration_to_computed_drop_exclusive(self):
await self.migrate(r'''
type User {
Expand Down