equal
deleted
inserted
replaced
48 """ |
48 """ |
49 |
49 |
50 __docformat__ = "restructuredtext en" |
50 __docformat__ = "restructuredtext en" |
51 |
51 |
52 import threading |
52 import threading |
53 from datetime import datetime, time |
|
54 |
53 |
55 from six.moves import range |
54 from six.moves import range |
56 |
55 |
57 from logilab.common.date import utcdatetime, utctime |
|
58 from logilab.database import FunctionDescr, SQL_FUNCTIONS_REGISTRY |
56 from logilab.database import FunctionDescr, SQL_FUNCTIONS_REGISTRY |
59 |
57 |
60 from rql import BadRQLQuery, CoercionError |
58 from rql import BadRQLQuery, CoercionError |
61 from rql.utils import common_parent |
59 from rql.utils import common_parent |
62 from rql.stmts import Union, Select |
60 from rql.stmts import Union, Select |
1516 return self._mapped_term(constant, '%%(%s)s' % value)[0] |
1514 return self._mapped_term(constant, '%%(%s)s' % value)[0] |
1517 except KeyError: |
1515 except KeyError: |
1518 _id = value |
1516 _id = value |
1519 if isinstance(_id, unicode): |
1517 if isinstance(_id, unicode): |
1520 _id = _id.encode() |
1518 _id = _id.encode() |
1521 # convert timestamp to utc. |
|
1522 # expect SET TiME ZONE to UTC at connection opening time. |
|
1523 # This shouldn't change anything for datetime without TZ. |
|
1524 value = self._args[_id] |
|
1525 if isinstance(value, datetime) and value.tzinfo is not None: |
|
1526 self._query_attrs[_id] = utcdatetime(value) |
|
1527 elif isinstance(value, time) and value.tzinfo is not None: |
|
1528 self._query_attrs[_id] = utctime(value) |
|
1529 else: |
1519 else: |
1530 _id = str(id(constant)).replace('-', '', 1) |
1520 _id = str(id(constant)).replace('-', '', 1) |
1531 self._query_attrs[_id] = value |
1521 self._query_attrs[_id] = value |
1532 return '%%(%s)s' % _id |
1522 return '%%(%s)s' % _id |
1533 |
1523 |