rset.py
branchstable
changeset 3016 5787d1cc8106
parent 2650 18aec79ec3a3
child 3023 7864fee8b4ec
child 3551 5a73db781dac
equal deleted inserted replaced
3015:0588e39f6743 3016:5787d1cc8106
   393         if len(rowvalues) > 1:
   393         if len(rowvalues) > 1:
   394             rqlst = self.syntax_tree()
   394             rqlst = self.syntax_tree()
   395             if rqlst.TYPE == 'select':
   395             if rqlst.TYPE == 'select':
   396                 # UNION query, find the subquery from which this entity has been
   396                 # UNION query, find the subquery from which this entity has been
   397                 # found
   397                 # found
   398                 rqlst = rqlst.locate_subquery(col, etype, self.args)
   398                 rqlst, col = rqlst.locate_subquery(col, etype, self.args)
   399             # take care, due to outer join support, we may find None
   399             # take care, due to outer join support, we may find None
   400             # values for non final relation
   400             # values for non final relation
   401             for i, attr, x in attr_desc_iterator(rqlst, col):
   401             for i, attr, x in attr_desc_iterator(rqlst, col):
   402                 if x == 'subject':
   402                 if x == 'subject':
   403                     rschema = eschema.subject_relation(attr)
   403                     rschema = eschema.subject_relation(attr)
   493                     etype = coletype
   493                     etype = coletype
   494                     locate_query_col = i
   494                     locate_query_col = i
   495                     if len(self.column_types(i)) > 1:
   495                     if len(self.column_types(i)) > 1:
   496                         break
   496                         break
   497         # UNION query, find the subquery from which this entity has been found
   497         # UNION query, find the subquery from which this entity has been found
   498         select = rqlst.locate_subquery(locate_query_col, etype, self.args)
   498         select = rqlst.locate_subquery(locate_query_col, etype, self.args)[0]
       
   499         col = rqlst.subquery_selection_index(select, col)
   499         try:
   500         try:
   500             myvar = select.selection[col].variable
   501             myvar = select.selection[col].variable
   501         except AttributeError:
   502         except AttributeError:
   502             # not a variable
   503             # not a variable
   503             return None, None
   504             return None, None
   504         rel = myvar.main_relation()
   505         rel = myvar.main_relation()
   505         if rel is not None:
   506         if rel is not None:
   506             index = rel.children[0].variable.selected_index()
   507             index = rel.children[0].root_selection_index()
   507             if index is not None and self.rows[row][index]:
   508             if index is not None and self.rows[row][index]:
   508                 return self.get_entity(row, index), rel.r_type
   509                 return self.get_entity(row, index), rel.r_type
   509         return None, None
   510         return None, None
   510 
   511 
   511     @cached
   512     @cached