Skip to content

Commit

Permalink
Add error when renaming module (#7149)
Browse files Browse the repository at this point in the history
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".
  • Loading branch information
dnwpark authored Apr 4, 2024
1 parent 1a7795e commit 4b3dca2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
13 changes: 13 additions & 0 deletions edb/schema/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 13 additions & 0 deletions tests/test_edgeql_ddl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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' {
Expand Down

0 comments on commit 4b3dca2

Please sign in to comment.