server/msplanner.py
branchstable
changeset 2190 d9f5fd1879fc
parent 2170 6adbc965c51b
child 2688 afa99d53401c
equal deleted inserted replaced
2189:08c66a83c3ca 2190:d9f5fd1879fc
   551           be fetched from some source
   551           be fetched from some source
   552         """
   552         """
   553         # NOTE: < 2 since may be 0 on queries such as Any X WHERE X eid 2
   553         # NOTE: < 2 since may be 0 on queries such as Any X WHERE X eid 2
   554         if len(self._sourcesterms) < 2:
   554         if len(self._sourcesterms) < 2:
   555             self.needsplit = False
   555             self.needsplit = False
       
   556             # if this is not the system source but we have only constant terms
       
   557             # and no relation (other than eid), apply query on the system source
       
   558             #
       
   559             # testing for rqlst with nothing in vargraph nor defined_vars is the
       
   560             # simplest way the check the condition explained below
       
   561             if not self.system_source in self._sourcesterms and \
       
   562                    not self.rqlst.vargraph and not self.rqlst.defined_vars:
       
   563                 self._sourcesterms = {self.system_source: {}}
   556         elif not self.needsplit:
   564         elif not self.needsplit:
   557             if not allequals(self._sourcesterms.itervalues()):
   565             if not allequals(self._sourcesterms.itervalues()):
   558                 for terms in self._sourcesterms.itervalues():
   566                 for source, terms in self._sourcesterms.iteritems():
       
   567                     if source is self.system_source:
       
   568                         continue
   559                     if any(x for x in terms if not isinstance(x, Constant)):
   569                     if any(x for x in terms if not isinstance(x, Constant)):
   560                         self.needsplit = True
   570                         self.needsplit = True
   561                         return
   571                         return
   562                 self._sourcesterms = {self.system_source: {}}
   572                 self._sourcesterms = {self.system_source: {}}
   563                 self.needsplit = False
   573                 self.needsplit = False