rset.py
changeset 572 9849fed789c9
parent 170 455ff18ef28e
child 616 545a7e18c47f
--- a/rset.py	Wed Feb 11 12:17:44 2009 +0100
+++ b/rset.py	Wed Feb 11 13:51:06 2009 +0100
@@ -464,7 +464,8 @@
         rqlst = self.syntax_tree()
         etype = self.description[row][col]
         if self.vreg.schema.eschema(etype).is_final():
-            # final type, find a better (ambiguous) one
+            # final type, find a better one to locate the correct subquery
+            # (ambiguous if possible) 
             for i in xrange(len(rqlst.children[0].selection)):
                 if i == col:
                     continue
@@ -476,18 +477,17 @@
                     locate_query_col = i
                     if len(self.column_types(i)) > 1:
                         break
-        # UNION query, find the subquery from which this entity has been
-        # found
+        # UNION query, find the subquery from which this entity has been found
         select = rqlst.locate_subquery(locate_query_col, etype, self.args)
         try:
             myvar = select.selection[col].variable
         except AttributeError:
-            # no .selection attribute is available
+            # not a variable
             return None, None
         rel = myvar.main_relation()
         if rel is not None:
             index = rel.children[0].variable.selected_index()
-            if index is not None:
+            if index is not None and self.rows[row][index]:
                 return self.get_entity(row, index), rel.r_type
         return None, None