From 4b3dca2931b9cc732f3f8ed777fb7a2dcf92eb73 Mon Sep 17 00:00:00 2001 From: dnwpark Date: Thu, 4 Apr 2024 10:48:08 -0400 Subject: [PATCH] Add error when renaming module (#7149) When renaming a module via DDL (eg. `ALTER MODULE foo RENAME TO bar`), a schema error is raised with the message "Renaming modules is not supported". --- edb/schema/modules.py | 13 +++++++++++++ tests/test_edgeql_ddl.py | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/edb/schema/modules.py b/edb/schema/modules.py index 8b8f6278388..d634ca30137 100644 --- a/edb/schema/modules.py +++ b/edb/schema/modules.py @@ -96,6 +96,19 @@ class AlterModule(ModuleCommand, sd.AlterObject[Module]): astnode = qlast.AlterModule +class RenameModule(ModuleCommand, sd.RenameObject[Module]): + + def apply( + self, + schema: s_schema.Schema, + context: sd.CommandContext, + ) -> s_schema.Schema: + raise errors.SchemaError( + f'renaming modules is not supported', + span=self.span, + ) + + class DeleteModule(ModuleCommand, sd.DeleteObject[Module]): astnode = qlast.DropModule diff --git a/tests/test_edgeql_ddl.py b/tests/test_edgeql_ddl.py index 0a34f5cf9c3..7c1a143ff5a 100644 --- a/tests/test_edgeql_ddl.py +++ b/tests/test_edgeql_ddl.py @@ -8750,6 +8750,19 @@ async def test_edgeql_ddl_modules_04(self): DROP MODULE test_other; """) + async def test_edgeql_ddl_modules_05(self): + await self.con.execute(r""" + CREATE MODULE foo; + """) + + async with self.assertRaisesRegexTx( + edgedb.SchemaError, + "renaming modules is not supported", + ): + await self.con.execute(r""" + ALTER MODULE foo RENAME TO bar; + """) + async def test_edgeql_ddl_extension_package_01(self): await self.con.execute(r""" CREATE EXTENSION PACKAGE foo_01 VERSION '1.0' {