From e8366b33246df96597431235becf1813e437bfe8 Mon Sep 17 00:00:00 2001 From: dnwpark Date: Mon, 7 Oct 2024 18:42:47 -0400 Subject: [PATCH] Look in std when using module alias. --- edb/schema/schema.py | 13 ++----------- tests/test_edgeql_expressions.py | 4 ++-- tests/test_schema.py | 3 ++- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/edb/schema/schema.py b/edb/schema/schema.py index f8696c4f82b7..b48fdc59fe7b 100644 --- a/edb/schema/schema.py +++ b/edb/schema/schema.py @@ -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' @@ -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: diff --git a/tests/test_edgeql_expressions.py b/tests/test_edgeql_expressions.py index b4cae692d7fa..1ea33a69ed50 100644 --- a/tests/test_edgeql_expressions.py +++ b/tests/test_edgeql_expressions.py @@ -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 += [ @@ -10243,7 +10243,7 @@ async def test_edgeql_expr_with_module_05(self): (REF_ERR, with_mod + 'select 1'), (NO_ERR, with_mod + 'select 1'), (NO_ERR, with_mod + 'select 1'), - (REF_ERR, with_mod + 'select 1'), + (NO_ERR, with_mod + 'select 1'), ] with_mod = 'with s as module std ' queries += [ diff --git a/tests/test_schema.py b/tests/test_schema.py index 6d4ec0def696..ecd3ca34734e 100644 --- a/tests/test_schema.py +++ b/tests/test_schema.py @@ -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 += [ @@ -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 += [