server/rqlannotation.py
changeset 9518 54ead5f372bb
parent 9361 0542a85fe667
child 9892 928732ec00dd
equal deleted inserted replaced
9517:3338b2205ea3 9518:54ead5f372bb
    33         if annotator._annotate_union(subquery.query):
    33         if annotator._annotate_union(subquery.query):
    34             has_text_query = True
    34             has_text_query = True
    35     #if server.DEBUG:
    35     #if server.DEBUG:
    36     #    print '-------- sql annotate', repr(rqlst)
    36     #    print '-------- sql annotate', repr(rqlst)
    37     getrschema = annotator.schema.rschema
    37     getrschema = annotator.schema.rschema
    38     need_distinct = rqlst.distinct
       
    39     for rel in rqlst.iget_nodes(Relation):
       
    40         if getrschema(rel.r_type).symmetric and not isinstance(rel.parent, Exists):
       
    41             for vref in rel.iget_nodes(VariableRef):
       
    42                 stinfo = vref.variable.stinfo
       
    43                 if not stinfo['constnode'] and stinfo['selected']:
       
    44                     need_distinct = True
       
    45                     # XXX could mark as not invariant
       
    46                     break
       
    47     for var in rqlst.defined_vars.itervalues():
    38     for var in rqlst.defined_vars.itervalues():
    48         stinfo = var.stinfo
    39         stinfo = var.stinfo
    49         if stinfo.get('ftirels'):
    40         if stinfo.get('ftirels'):
    50             has_text_query = True
    41             has_text_query = True
    51         if stinfo['attrvar']:
    42         if stinfo['attrvar']:
   156     # see unittest_rqlannotation. test_has_text_security_cache_bug
   147     # see unittest_rqlannotation. test_has_text_security_cache_bug
   157     # XXX probably more to do, but yet that work without more...
   148     # XXX probably more to do, but yet that work without more...
   158     for col_alias in rqlst.aliases.itervalues():
   149     for col_alias in rqlst.aliases.itervalues():
   159         if col_alias.stinfo.get('ftirels'):
   150         if col_alias.stinfo.get('ftirels'):
   160             has_text_query = True
   151             has_text_query = True
   161     rqlst.need_distinct = need_distinct
       
   162     return has_text_query
   152     return has_text_query
   163 
   153 
   164 
   154 
   165 
   155 
   166 class CantSelectPrincipal(Exception):
   156 class CantSelectPrincipal(Exception):