Skip to content

Commit ff08d9d

Browse files
msullivanaljazerzen
authored andcommitted
Fix globals in nested modules (#474)
Fixes #472.
1 parent f271171 commit ff08d9d

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

edgedb/options.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -182,15 +182,15 @@ def with_config(self, *args, **config):
182182
)
183183

184184
def resolve(self, name: str) -> str:
185-
parts = name.split("::")
185+
parts = name.split("::", 1)
186186
if len(parts) == 1:
187187
return f"{self._module or 'default'}::{name}"
188188
elif len(parts) == 2:
189189
mod, name = parts
190190
mod = self._aliases.get(mod, mod)
191191
return f"{mod}::{name}"
192192
else:
193-
raise errors.InvalidArgumentError(f"Illegal name: {name}")
193+
raise AssertionError('broken split')
194194

195195
def with_globals(self, *args, **globals_):
196196
if len(args) > 1:

tests/test_globals.py

+7
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ async def test_globals_01(self):
3636
CREATE GLOBAL def_glob -> str {
3737
SET default := '!';
3838
};
39+
CREATE MODULE foo;
40+
CREATE MODULE foo::bar;
41+
CREATE GLOBAL foo::bar::baz -> str;
3942
''')
4043

4144
async with db.with_globals(glob='test') as gdb:
@@ -61,6 +64,10 @@ async def test_globals_01(self):
6164
x = await gdb.query_single('select global def_glob')
6265
self.assertEqual(x, None)
6366

67+
async with db.with_globals({'foo::bar::baz': 'asdf'}) as gdb:
68+
x = await gdb.query_single('select global foo::bar::baz')
69+
self.assertEqual(x, 'asdf')
70+
6471
async def test_client_state_mismatch(self):
6572
db = self.client
6673
if db.is_proto_lt_1_0:

0 commit comments

Comments
 (0)