From 0c24ca8861d62d0a61eba97fc13c9cabfd7c6801 Mon Sep 17 00:00:00 2001 From: "Michael J. Sullivan" Date: Wed, 24 Jan 2024 09:41:14 -0800 Subject: [PATCH] Make overloading a link when omitting `link` keyword work (#6718) AlterUnknownPointer works by converting the AST node into an operation on the relevant concrete pointer sort. It always converted into an Alter, though, which meant that the overload case, where AlterObject._cmd_tree_from_ast is called with a Create node, didn't work right. Fixes #6716. --- edb/schema/unknown_pointers.py | 4 ++++ tests/test_schema.py | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/edb/schema/unknown_pointers.py b/edb/schema/unknown_pointers.py index 88be760f24b..8ff96f7bd22 100644 --- a/edb/schema/unknown_pointers.py +++ b/edb/schema/unknown_pointers.py @@ -166,6 +166,10 @@ def _cmd_tree_from_ast( qlast.AlterConcreteProperty if isinstance(obj, s_props.Property) else qlast.AlterConcreteLink + ) if isinstance(astnode, qlast.AlterObject) else ( + qlast.CreateConcreteProperty + if isinstance(obj, s_props.Property) + else qlast.CreateConcreteLink ) astnode = astnode.replace(__class__=astcls) qlparser.append_module_aliases(astnode, context.modaliases) diff --git a/tests/test_schema.py b/tests/test_schema.py index fb32673722d..104228961ec 100644 --- a/tests/test_schema.py +++ b/tests/test_schema.py @@ -10200,6 +10200,27 @@ def test_schema_describe_name_override_03(self): """ ) + def test_schema_describe_overload_01(self): + self._assert_describe( + """ + abstract type Animal { + name: str; + parent: Animal; + } + type Human extending Animal { + overloaded parent: Human; + } + """, + + 'describe type test::Human as sdl', + + """ + type test::Human extending test::Animal { + overloaded link parent: test::Human; + }; + """, + ) + class TestCreateMigration(tb.BaseSchemaTest):