Commits

Kirill Simonov  committed 8dd7662

Report ambiguous lookup rather than ignore it.

  • Participants
  • Parent commits fc66d1f

Comments (0)

Files changed (3)

File src/htsql/tr/bind.py

                      ComplementSyntax, StringSyntax, NumberSyntax)
 from .recipe import (Recipe, FreeTableRecipe, AttachedTableRecipe,
                      ColumnRecipe, ComplementRecipe, KernelRecipe,
-                     SubstitutionRecipe, BindingRecipe)
+                     SubstitutionRecipe, BindingRecipe, AmbiguousRecipe)
 from .binding import (Binding, RootBinding, QueryBinding, SegmentBinding,
                       LiteralBinding, SieveBinding, CastBinding,
                       WrapperBinding, FreeTableBinding, AttachedTableBinding,
         return self.recipe.binding
 
 
+class BindByAmbiguous(BindByRecipe):
+
+    adapts(AmbiguousRecipe)
+
+    def __call__(self):
+        raise BindError("ambiguous name", self.syntax.mark)
+
+
 def bind_all(syntax, state=None, base=None):
     """
     Binds the given syntax node.

File src/htsql/tr/lookup.py

                       DefinitionBinding, RedirectBinding, AliasBinding)
 from .recipe import (FreeTableRecipe, AttachedTableRecipe, ColumnRecipe,
                      ComplementRecipe, KernelRecipe, SubstitutionRecipe,
-                     BindingRecipe)
+                     BindingRecipe, AmbiguousRecipe)
 import re
 import unicodedata
 
         if len(candidates) == 1:
             table = candidates[0]
             return FreeTableRecipe(table)
+        if len(candidates) > 1:
+            return AmbiguousRecipe()
 
 
 class LookupItemizeTableMixin(object):
             # Build and return the link binding.
             return AttachedTableRecipe(joins)
 
+        if len(candidates) > 1:
+            return AmbiguousRecipe()
+
 
 class LookupTable(Lookup, LookupItemizeTableMixin):
     """
             column = candidates[0]
             link = self.find_link(column)
             return ColumnRecipe(column, link)
+        if len(candidates) > 1:
+            return AmbiguousRecipe()
 
     def lookup_direct_join(self):
         # Finds a table referenced from the context table that matches
             target = target_schema.tables[foreign_key.target_name]
             join = DirectJoin(origin, target, foreign_key)
             return AttachedTableRecipe([join])
+        if len(candidates) > 1:
+            return AmbiguousRecipe()
 
     def lookup_reverse_join(self):
         # Finds a table with the given name that possesses a foreign key
             target = target_schema.tables[foreign_key.origin_name]
             join = ReverseJoin(origin, target, foreign_key)
             return AttachedTableRecipe([join])
+        if len(candidates) > 1:
+            return AmbiguousRecipe()
 
 
 class ItemizeTable(Itemize, LookupItemizeTableMixin):

File src/htsql/tr/recipe.py

         self.binding = binding
 
 
+class AmbiguousRecipe(Recipe):
+    pass
+
+