cubicweb/server/sources/rql2sql.py
changeset 12567 26744ad37953
parent 12296 23bc9f385645
child 12828 dadbd4148a44
equal deleted inserted replaced
12566:6b3523f81f42 12567:26744ad37953
    46 
    46 
    47 .. _Comparison of different SQL implementations: http://www.troels.arvin.dk/db/rdbms
    47 .. _Comparison of different SQL implementations: http://www.troels.arvin.dk/db/rdbms
    48 """
    48 """
    49 
    49 
    50 import threading
    50 import threading
    51 
       
    52 from six import PY2, text_type
       
    53 from six.moves import range
       
    54 
    51 
    55 from logilab.database import FunctionDescr, SQL_FUNCTIONS_REGISTRY
    52 from logilab.database import FunctionDescr, SQL_FUNCTIONS_REGISTRY
    56 
    53 
    57 from rql import BadRQLQuery, CoercionError
    54 from rql import BadRQLQuery, CoercionError
    58 from rql.utils import common_parent
    55 from rql.utils import common_parent
  1515             if rel is not None:
  1512             if rel is not None:
  1516                 rel._q_needcast = value
  1513                 rel._q_needcast = value
  1517             return self.keyword_map[value]()
  1514             return self.keyword_map[value]()
  1518         if constant.type == 'Substitute':
  1515         if constant.type == 'Substitute':
  1519             _id = value
  1516             _id = value
  1520             if PY2 and isinstance(_id, text_type):
       
  1521                 _id = _id.encode()
       
  1522         else:
  1517         else:
  1523             _id = str(id(constant)).replace('-', '', 1)
  1518             _id = str(id(constant)).replace('-', '', 1)
  1524             self._query_attrs[_id] = value
  1519             self._query_attrs[_id] = value
  1525         return '%%(%s)s' % _id
  1520         return '%%(%s)s' % _id
  1526 
  1521