diff --git a/edb/edgeql/parser/grammar/config.py b/edb/edgeql/parser/grammar/config.py index 3ec9eb6f482..aef88f82b1d 100644 --- a/edb/edgeql/parser/grammar/config.py +++ b/edb/edgeql/parser/grammar/config.py @@ -36,6 +36,9 @@ def reduce_SESSION(self, _): def reduce_CURRENT_DATABASE(self, _c, _d): self.val = qltypes.ConfigScope.DATABASE + def reduce_CURRENT_BRANCH(self, _c, _d): + self.val = qltypes.ConfigScope.DATABASE + def reduce_SYSTEM(self, _): self.val = qltypes.ConfigScope.INSTANCE @@ -74,6 +77,14 @@ def reduce_CONFIGURE_DATABASE_ConfigOp(self, configure, database, _config): f"{database.val}'?", context=database.context) + def reduce_CONFIGURE_BRANCH_ConfigOp(self, configure, database, _config): + raise errors.EdgeQLSyntaxError( + f"'{configure.val} {database.val}' is invalid syntax. " + f"Did you mean '{configure.val} " + f"{'current' if database.val[0] == 'd' else 'CURRENT'} " + f"{database.val}'?", + context=database.context) + def reduce_CONFIGURE_ConfigScope_ConfigOp(self, _, scope, op): self.val = op.val self.val.scope = scope.val diff --git a/edb/edgeql/parser/grammar/statements.py b/edb/edgeql/parser/grammar/statements.py index 28ef96ae162..b2d3ca549e1 100644 --- a/edb/edgeql/parser/grammar/statements.py +++ b/edb/edgeql/parser/grammar/statements.py @@ -214,6 +214,14 @@ def reduce_DESCRIBE_CURRENT_DATABASE_CONFIG(self, *kids): options=kids[4].val.options, ) + def reduce_DESCRIBE_CURRENT_BRANCH_CONFIG(self, *kids): + """%reduce DESCRIBE CURRENT BRANCH CONFIG DescribeFormat""" + self.val = qlast.DescribeStmt( + object=qlast.DescribeGlobal.DatabaseConfig, + language=kids[4].val.language, + options=kids[4].val.options, + ) + def reduce_DESCRIBE_INSTANCE_CONFIG(self, *kids): """%reduce DESCRIBE INSTANCE CONFIG DescribeFormat""" self.val = qlast.DescribeStmt( diff --git a/edb/edgeql/qltypes.py b/edb/edgeql/qltypes.py index 03e85d0e703..cad698139f9 100644 --- a/edb/edgeql/qltypes.py +++ b/edb/edgeql/qltypes.py @@ -313,7 +313,7 @@ class ConfigScope(s_enum.StrEnum): def to_edgeql(self) -> str: if self is ConfigScope.DATABASE: - return 'CURRENT DATABASE' + return 'CURRENT BRANCH' else: return str(self) diff --git a/tests/test_edgeql_extensions.py b/tests/test_edgeql_extensions.py index f5e493c1bba..c5231112fe3 100644 --- a/tests/test_edgeql_extensions.py +++ b/tests/test_edgeql_extensions.py @@ -551,7 +551,7 @@ async def _check(_cfg_obj='Config', **kwargs): edgedb.ConstraintViolationError, "" ): await self.con.execute(''' - CONFIGURE CURRENT DATABASE INSERT ext::_conf::SingleObj { + CONFIGURE CURRENT BRANCH INSERT ext::_conf::SingleObj { name := 'fail', value := '', }; @@ -709,42 +709,42 @@ async def _check(_cfg_obj='Config', **kwargs): ) val = await self.con.query_single(''' - describe current database config + describe current branch config ''') test_expected = textwrap.dedent('''\ - CONFIGURE CURRENT DATABASE SET ext::_conf::Config::config_name := \ + CONFIGURE CURRENT BRANCH SET ext::_conf::Config::config_name := \ 'ready'; - CONFIGURE CURRENT DATABASE INSERT ext::_conf::SingleObj { + CONFIGURE CURRENT BRANCH INSERT ext::_conf::SingleObj { name := 'single', value := 'val', }; - CONFIGURE CURRENT DATABASE INSERT ext::_conf::Obj { + CONFIGURE CURRENT BRANCH INSERT ext::_conf::Obj { name := '1', value := 'foo', }; - CONFIGURE CURRENT DATABASE INSERT ext::_conf::Obj { + CONFIGURE CURRENT BRANCH INSERT ext::_conf::Obj { name := '2', opt_value := 'opt.', value := 'bar', }; - CONFIGURE CURRENT DATABASE INSERT ext::_conf::SecretObj { + CONFIGURE CURRENT BRANCH INSERT ext::_conf::SecretObj { name := '4', secret := {}, # REDACTED value := 'foo', }; - CONFIGURE CURRENT DATABASE INSERT ext::_conf::SecretObj { + CONFIGURE CURRENT BRANCH INSERT ext::_conf::SecretObj { name := '5', secret := {}, # REDACTED value := 'quux', }; - CONFIGURE CURRENT DATABASE INSERT ext::_conf::SubObj { + CONFIGURE CURRENT BRANCH INSERT ext::_conf::SubObj { duration_config := 'PT10M', extra := 42, name := '3', value := 'baz', }; - CONFIGURE CURRENT DATABASE SET ext::_conf::Config::opt_value := 'opt!'; - CONFIGURE CURRENT DATABASE SET ext::_conf::Config::secret := \ + CONFIGURE CURRENT BRANCH SET ext::_conf::Config::opt_value := 'opt!'; + CONFIGURE CURRENT BRANCH SET ext::_conf::Config::secret := \ {}; # REDACTED ''') self.assertEqual(val, test_expected) @@ -805,7 +805,7 @@ async def _check(_cfg_obj='Config', **kwargs): try: await con2.query('select 1') await self.con.execute(''' - CONFIGURE CURRENT DATABASE INSERT ext::_conf::Obj { + CONFIGURE CURRENT BRANCH INSERT ext::_conf::Obj { name := 'fail', value := '', }; @@ -816,7 +816,7 @@ async def _check(_cfg_obj='Config', **kwargs): edgedb.ConstraintViolationError, "" ): await self.con.execute(''' - CONFIGURE CURRENT DATABASE INSERT ext::_conf::Obj { + CONFIGURE CURRENT BRANCH INSERT ext::_conf::Obj { name := 'fail', value := '', }; diff --git a/tests/test_edgeql_syntax.py b/tests/test_edgeql_syntax.py index fc2e2ac9ce8..52fbd13dfca 100644 --- a/tests/test_edgeql_syntax.py +++ b/tests/test_edgeql_syntax.py @@ -5624,25 +5624,25 @@ def test_edgeql_syntax_configure_01(self): """ CONFIGURE INSTANCE SET foo := (SELECT User); CONFIGURE SESSION SET foo := (SELECT User); - CONFIGURE CURRENT DATABASE SET foo := (SELECT User); + CONFIGURE CURRENT BRANCH SET foo := (SELECT User); CONFIGURE INSTANCE SET cfg::foo := (SELECT User); CONFIGURE SESSION SET cfg::foo := (SELECT User); - CONFIGURE CURRENT DATABASE SET cfg::foo := (SELECT User); + CONFIGURE CURRENT BRANCH SET cfg::foo := (SELECT User); CONFIGURE INSTANCE RESET foo; CONFIGURE SESSION RESET foo; - CONFIGURE CURRENT DATABASE RESET foo; + CONFIGURE CURRENT BRANCH RESET foo; CONFIGURE INSTANCE RESET cfg::foo; CONFIGURE SESSION RESET cfg::foo; - CONFIGURE CURRENT DATABASE RESET cfg::foo; + CONFIGURE CURRENT BRANCH RESET cfg::foo; CONFIGURE INSTANCE INSERT Foo {bar := (SELECT 1)}; CONFIGURE SESSION INSERT Foo {bar := (SELECT 1)}; - CONFIGURE CURRENT DATABASE INSERT Foo {bar := (SELECT 1)}; + CONFIGURE CURRENT BRANCH INSERT Foo {bar := (SELECT 1)}; CONFIGURE INSTANCE INSERT cfg::Foo {bar := (SELECT 1)}; CONFIGURE SESSION INSERT cfg::Foo {bar := (SELECT 1)}; - CONFIGURE CURRENT DATABASE INSERT cfg::Foo {bar := (SELECT 1)}; + CONFIGURE CURRENT BRANCH INSERT cfg::Foo {bar := (SELECT 1)}; CONFIGURE INSTANCE RESET Foo FILTER (.bar = 2); CONFIGURE SESSION RESET Foo FILTER (.bar = 2); - CONFIGURE CURRENT DATABASE RESET Foo FILTER (.bar = 2); + CONFIGURE CURRENT BRANCH RESET Foo FILTER (.bar = 2); """ @tb.must_fail( diff --git a/tests/test_server_config.py b/tests/test_server_config.py index 87f4c876f66..17bbb4f6716 100644 --- a/tests/test_server_config.py +++ b/tests/test_server_config.py @@ -1083,7 +1083,7 @@ async def test_server_proto_configure_describe_system_config(self): async def test_server_proto_configure_describe_database_config(self): try: conf1 = ( - "CONFIGURE CURRENT DATABASE " + "CONFIGURE CURRENT BRANCH " "SET singleprop := '1337';" ) await self.con.execute(conf1)