rset.py
changeset 6225 a176e68b7d0d
parent 6142 8bc6eac1fac1
parent 6196 12fdccedab5a
child 6857 8d2062387134
equal deleted inserted replaced
6182:30de0be8f895 6225:a176e68b7d0d
   567                     continue
   567                     continue
   568                 for i in xrange(len(select.selection)):
   568                 for i in xrange(len(select.selection)):
   569                     if i == col:
   569                     if i == col:
   570                         continue
   570                         continue
   571                     coletype = self.description[row][i]
   571                     coletype = self.description[row][i]
   572                     # None description possible on column resulting from an outer join
   572                     # None description possible on column resulting from an
       
   573                     # outer join
   573                     if coletype is None or eschema(coletype).final:
   574                     if coletype is None or eschema(coletype).final:
   574                         continue
   575                         continue
   575                     try:
   576                     try:
   576                         ivar = select.selection[i].variable
   577                         ivar = select.selection[i].variable
   577                     except AttributeError:
   578                     except AttributeError:
   586                             return etype, locate_query_col
   587                             return etype, locate_query_col
   587         return etype, locate_query_col
   588         return etype, locate_query_col
   588 
   589 
   589     @cached
   590     @cached
   590     def related_entity(self, row, col):
   591     def related_entity(self, row, col):
   591         """try to get the related entity to extract format information if any"""
   592         """given an cell of the result set, try to return a (entity, relation
       
   593         name) tuple to which this cell is linked.
       
   594 
       
   595         This is especially useful when the cell is an attribute of an entity,
       
   596         to get the entity to which this attribute belongs to.
       
   597         """
   592         rqlst = self.syntax_tree()
   598         rqlst = self.syntax_tree()
       
   599         # UNION query, we've first to find a 'pivot' column to use to get the
       
   600         # actual query from which the row is coming
   593         etype, locate_query_col = self._locate_query_params(rqlst, row, col)
   601         etype, locate_query_col = self._locate_query_params(rqlst, row, col)
   594         # UNION query, find the subquery from which this entity has been found
   602         # now find the query from which this entity has been found. Returned
       
   603         # select node may be a subquery with different column indexes.
   595         select = rqlst.locate_subquery(locate_query_col, etype, self.args)[0]
   604         select = rqlst.locate_subquery(locate_query_col, etype, self.args)[0]
       
   605         # then get the index of root query's col in the subquery
   596         col = rqlst.subquery_selection_index(select, col)
   606         col = rqlst.subquery_selection_index(select, col)
   597         if col is None:
   607         if col is None:
   598             # XXX unexpected, should fix subquery_selection_index ?
   608             # XXX unexpected, should fix subquery_selection_index ?
   599             return None, None
   609             return None, None
   600         try:
   610         try: