server/rqlannotation.py
branchstable
changeset 4287 15499a46c009
parent 4285 ea590101691c
child 4467 0e73d299730a
equal deleted inserted replaced
4286:6801093af29c 4287:15499a46c009
   187             continue
   187             continue
   188         if rel.sqlscope is rel.stmt:
   188         if rel.sqlscope is rel.stmt:
   189             return rel
   189             return rel
   190         principal = rel
   190         principal = rel
   191     if principal is None:
   191     if principal is None:
   192         print iter(relations).next().root
       
   193         raise BadRQLQuery('unable to find principal in %s' % ', '.join(
   192         raise BadRQLQuery('unable to find principal in %s' % ', '.join(
   194             r.as_string() for r in relations))
   193             r.as_string() for r in relations))
   195     return principal
   194     return principal
   196 
   195 
   197 
   196 
   308         if not self.ambiguousvars:
   307         if not self.ambiguousvars:
   309             return
   308             return
   310         # apply relation restriction
   309         # apply relation restriction
   311         self.maydeambrels = maydeambrels = {}
   310         self.maydeambrels = maydeambrels = {}
   312         for rel in rqlst.iget_nodes(Relation):
   311         for rel in rqlst.iget_nodes(Relation):
   313             if rel.is_types_restriction() or rel.r_type == 'eid':
   312             if rel.r_type == 'eid' or rel.is_types_restriction():
   314                 continue
   313                 continue
   315             lhs, rhs = rel.get_variable_parts()
   314             lhs, rhs = rel.get_variable_parts()
   316             if isinstance(lhs, VariableRef) or isinstance(rhs, VariableRef):
   315             if isinstance(lhs, VariableRef) or isinstance(rhs, VariableRef):
   317                 rschema = self.rschema(rel.r_type)
   316                 rschema = self.rschema(rel.r_type)
   318                 if rschema.inlined or rschema.final:
   317                 if rschema.inlined or rschema.final:
   383             else:
   382             else:
   384                 rtypefunc = rschema.objects
   383                 rtypefunc = rschema.objects
   385             for otheretype in otheretypes:
   384             for otheretype in otheretypes:
   386                 reltypes = frozenset(rtypefunc(otheretype))
   385                 reltypes = frozenset(rtypefunc(otheretype))
   387                 if var.stinfo['possibletypes'] != reltypes:
   386                 if var.stinfo['possibletypes'] != reltypes:
   388                     break
   387                     return False
   389             else:
   388             self.restrict(var, var.stinfo['possibletypes'])
   390                 self.restrict(var, var.stinfo['possibletypes'])
   389             self.deambification_map[var] = deambiguifier
   391                 self.deambification_map[var] = deambiguifier
   390             return True
   392                 return True
       
   393         return False
   391         return False