server/sources/rql2sql.py
changeset 10609 e2d8e81bfe68
parent 10522 1660a0fa4f43
child 10651 9ca33768473c
equal deleted inserted replaced
10608:7fc548d9dd8e 10609:e2d8e81bfe68
    49 
    49 
    50 __docformat__ = "restructuredtext en"
    50 __docformat__ = "restructuredtext en"
    51 
    51 
    52 import threading
    52 import threading
    53 from datetime import datetime, time
    53 from datetime import datetime, time
       
    54 
       
    55 from six.moves import range
    54 
    56 
    55 from logilab.common.date import utcdatetime, utctime
    57 from logilab.common.date import utcdatetime, utctime
    56 from logilab.database import FunctionDescr, SQL_FUNCTIONS_REGISTRY
    58 from logilab.database import FunctionDescr, SQL_FUNCTIONS_REGISTRY
    57 
    59 
    58 from rql import BadRQLQuery, CoercionError
    60 from rql import BadRQLQuery, CoercionError
   187                 thisexistssols, thisexistsvars = existssols[var.scope]
   189                 thisexistssols, thisexistsvars = existssols[var.scope]
   188             except KeyError:
   190             except KeyError:
   189                 thisexistssols = [newsols[0]]
   191                 thisexistssols = [newsols[0]]
   190                 thisexistsvars = set()
   192                 thisexistsvars = set()
   191                 existssols[var.scope] = thisexistssols, thisexistsvars
   193                 existssols[var.scope] = thisexistssols, thisexistsvars
   192             for i in xrange(len(newsols)-1, 0, -1):
   194             for i in range(len(newsols)-1, 0, -1):
   193                 if vtype != newsols[i][vname]:
   195                 if vtype != newsols[i][vname]:
   194                     thisexistssols.append(newsols.pop(i))
   196                     thisexistssols.append(newsols.pop(i))
   195                     thisexistsvars.add(vname)
   197                     thisexistsvars.add(vname)
   196         else:
   198         else:
   197             # remember unstable variables
   199             # remember unstable variables
   198             for i in xrange(1, len(newsols)):
   200             for i in range(1, len(newsols)):
   199                 if vtype != newsols[i][vname]:
   201                 if vtype != newsols[i][vname]:
   200                     unstable.add(vname)
   202                     unstable.add(vname)
   201     if invariants:
   203     if invariants:
   202         # filter out duplicates
   204         # filter out duplicates
   203         newsols_ = []
   205         newsols_ = []