Skip to content

Commit

Permalink
Look in std when using module alias.
Browse files Browse the repository at this point in the history
  • Loading branch information
dnwpark committed Oct 7, 2024
1 parent c954d1a commit e8366b3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
13 changes: 2 additions & 11 deletions edb/schema/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -1128,12 +1128,7 @@ def _search_with_getter(
return result

# Try something in std, but only if there isn't a module clash
if not local and (
orig_module is None
or (
not alias_hit and module
)
):
if not local:
# If no module was specified, look in std
if orig_module is None:
mod_name = 'std'
Expand All @@ -1151,11 +1146,7 @@ def _search_with_getter(
self.has_module(fmod := module.split('::')[0])
or (disallow_module and disallow_module(fmod))
):
mod_name = (
f'std::{module}'
if orig_module is None
else f'std::{orig_module}'
)
mod_name = f'std::{module}'
fqname = sn.QualName(mod_name, shortname)
result = getter(self, fqname)
if result is not None:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_edgeql_expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -10094,7 +10094,7 @@ async def test_edgeql_expr_with_module_03(self):
(REF_ERR, with_mod + 'select abs(1)'),
(NO_ERR, with_mod + 'select _test::abs(1)'),
(NO_ERR, with_mod + 'select std::_test::abs(1)'),
(REF_ERR, with_mod + 'select t::abs(1)'),
(NO_ERR, with_mod + 'select t::abs(1)'),
]
with_mod = 'with s as module std '
queries += [
Expand Down Expand Up @@ -10243,7 +10243,7 @@ async def test_edgeql_expr_with_module_05(self):
(REF_ERR, with_mod + 'select <Foo>1'),
(NO_ERR, with_mod + 'select <test::Foo>1'),
(NO_ERR, with_mod + 'select <std::test::Foo>1'),
(REF_ERR, with_mod + 'select <t::Foo>1'),
(NO_ERR, with_mod + 'select <t::Foo>1'),
]
with_mod = 'with s as module std '
queries += [
Expand Down
3 changes: 2 additions & 1 deletion tests/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -3306,7 +3306,7 @@ def test_schema_with_module_03(self):
(REF_ERR, with_mod + 'select abs(1)'),
(NO_ERR, with_mod + 'select _test::abs(1)'),
(NO_ERR, with_mod + 'select std::_test::abs(1)'),
(REF_ERR, with_mod + 'select t::abs(1)'),
(NO_ERR, with_mod + 'select t::abs(1)'),
]
with_mod = 'with s as module std '
queries += [
Expand Down Expand Up @@ -11624,6 +11624,7 @@ def test_schema_describe_with_module_03(self):
queries += [
with_mod + 'select _test::abs(1)',
with_mod + 'select std::_test::abs(1)',
with_mod + 'select t::abs(1)',
]
with_mod = 'with s as module std '
queries += [
Expand Down

0 comments on commit e8366b3

Please sign in to comment.