462 """try to get the related entity to extract format information if any""" |
462 """try to get the related entity to extract format information if any""" |
463 locate_query_col = col |
463 locate_query_col = col |
464 rqlst = self.syntax_tree() |
464 rqlst = self.syntax_tree() |
465 etype = self.description[row][col] |
465 etype = self.description[row][col] |
466 if self.vreg.schema.eschema(etype).is_final(): |
466 if self.vreg.schema.eschema(etype).is_final(): |
467 # final type, find a better (ambiguous) one |
467 # final type, find a better one to locate the correct subquery |
|
468 # (ambiguous if possible) |
468 for i in xrange(len(rqlst.children[0].selection)): |
469 for i in xrange(len(rqlst.children[0].selection)): |
469 if i == col: |
470 if i == col: |
470 continue |
471 continue |
471 coletype = self.description[row][i] |
472 coletype = self.description[row][i] |
472 if coletype is None: |
473 if coletype is None: |
474 if not self.vreg.schema.eschema(coletype).is_final(): |
475 if not self.vreg.schema.eschema(coletype).is_final(): |
475 etype = coletype |
476 etype = coletype |
476 locate_query_col = i |
477 locate_query_col = i |
477 if len(self.column_types(i)) > 1: |
478 if len(self.column_types(i)) > 1: |
478 break |
479 break |
479 # UNION query, find the subquery from which this entity has been |
480 # UNION query, find the subquery from which this entity has been found |
480 # found |
|
481 select = rqlst.locate_subquery(locate_query_col, etype, self.args) |
481 select = rqlst.locate_subquery(locate_query_col, etype, self.args) |
482 try: |
482 try: |
483 myvar = select.selection[col].variable |
483 myvar = select.selection[col].variable |
484 except AttributeError: |
484 except AttributeError: |
485 # no .selection attribute is available |
485 # not a variable |
486 return None, None |
486 return None, None |
487 rel = myvar.main_relation() |
487 rel = myvar.main_relation() |
488 if rel is not None: |
488 if rel is not None: |
489 index = rel.children[0].variable.selected_index() |
489 index = rel.children[0].variable.selected_index() |
490 if index is not None: |
490 if index is not None and self.rows[row][index]: |
491 return self.get_entity(row, index), rel.r_type |
491 return self.get_entity(row, index), rel.r_type |
492 return None, None |
492 return None, None |
493 |
493 |
494 @cached |
494 @cached |
495 def searched_text(self): |
495 def searched_text(self): |