server/rqlannotation.py
branchstable
changeset 2199 bd0a0f219751
parent 1977 606923dff11b
child 2353 b11f1068a0d3
equal deleted inserted replaced
2198:ac45d4dbaf76 2199:bd0a0f219751
    20     #    print '-------- sql annotate', repr(rqlst)
    20     #    print '-------- sql annotate', repr(rqlst)
    21     getrschema = annotator.schema.rschema
    21     getrschema = annotator.schema.rschema
    22     has_text_query = False
    22     has_text_query = False
    23     need_distinct = rqlst.distinct
    23     need_distinct = rqlst.distinct
    24     for rel in rqlst.iget_nodes(Relation):
    24     for rel in rqlst.iget_nodes(Relation):
    25         if rel.neged(strict=True):
    25         if getrschema(rel.r_type).symetric:
    26             if rel.is_types_restriction():
       
    27                 need_distinct = True
       
    28             else:
       
    29                 rschema = getrschema(rel.r_type)
       
    30                 if not rschema.is_final():
       
    31                     if rschema.inlined:
       
    32                         try:
       
    33                             var = rel.children[1].children[0].variable
       
    34                         except AttributeError:
       
    35                             pass # rewritten variable
       
    36                         else:
       
    37                             if not var.stinfo['constnode']:
       
    38                                 need_distinct = True
       
    39         elif getrschema(rel.r_type).symetric:
       
    40             for vref in rel.iget_nodes(VariableRef):
    26             for vref in rel.iget_nodes(VariableRef):
    41                 stinfo = vref.variable.stinfo
    27                 stinfo = vref.variable.stinfo
    42                 if not stinfo['constnode'] and stinfo['selected']:
    28                 if not stinfo['constnode'] and stinfo['selected']:
    43                     need_distinct = True
    29                     need_distinct = True
    44                     # XXX could mark as not invariant
    30                     # XXX could mark as not invariant