server/sources/rql2sql.py
changeset 10677 59ec0aaae08b
parent 10669 155c29e0ed1c
child 11293 63c589e6b076
equal deleted inserted replaced
10676:9d6b79081bad 10677:59ec0aaae08b
    49 
    49 
    50 __docformat__ = "restructuredtext en"
    50 __docformat__ = "restructuredtext en"
    51 
    51 
    52 import threading
    52 import threading
    53 
    53 
       
    54 from six import PY2
    54 from six.moves import range
    55 from six.moves import range
    55 
    56 
    56 from logilab.database import FunctionDescr, SQL_FUNCTIONS_REGISTRY
    57 from logilab.database import FunctionDescr, SQL_FUNCTIONS_REGISTRY
    57 
    58 
    58 from rql import BadRQLQuery, CoercionError
    59 from rql import BadRQLQuery, CoercionError
  1512             try:
  1513             try:
  1513                 # we may found constant from simplified var in varmap
  1514                 # we may found constant from simplified var in varmap
  1514                 return self._mapped_term(constant, '%%(%s)s' % value)[0]
  1515                 return self._mapped_term(constant, '%%(%s)s' % value)[0]
  1515             except KeyError:
  1516             except KeyError:
  1516                 _id = value
  1517                 _id = value
  1517                 if isinstance(_id, unicode):
  1518                 if PY2 and isinstance(_id, unicode):
  1518                     _id = _id.encode()
  1519                     _id = _id.encode()
  1519         else:
  1520         else:
  1520             _id = str(id(constant)).replace('-', '', 1)
  1521             _id = str(id(constant)).replace('-', '', 1)
  1521             self._query_attrs[_id] = value
  1522             self._query_attrs[_id] = value
  1522         return '%%(%s)s' % _id
  1523         return '%%(%s)s' % _id