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 |
53 |
54 |
|
55 from logilab.common.date import utcdatetime, utctime |
|
56 from logilab.database import FunctionDescr, SQL_FUNCTIONS_REGISTRY |
54 from logilab.database import FunctionDescr, SQL_FUNCTIONS_REGISTRY |
57 |
55 |
58 from rql import BadRQLQuery, CoercionError |
56 from rql import BadRQLQuery, CoercionError |
59 from rql.utils import common_parent |
57 from rql.utils import common_parent |
60 from rql.stmts import Union, Select |
58 from rql.stmts import Union, Select |
1514 return self._mapped_term(constant, '%%(%s)s' % value)[0] |
1512 return self._mapped_term(constant, '%%(%s)s' % value)[0] |
1515 except KeyError: |
1513 except KeyError: |
1516 _id = value |
1514 _id = value |
1517 if isinstance(_id, unicode): |
1515 if isinstance(_id, unicode): |
1518 _id = _id.encode() |
1516 _id = _id.encode() |
1519 # convert timestamp to utc. |
|
1520 # expect SET TiME ZONE to UTC at connection opening time. |
|
1521 # This shouldn't change anything for datetime without TZ. |
|
1522 value = self._args[_id] |
|
1523 if isinstance(value, datetime) and value.tzinfo is not None: |
|
1524 self._query_attrs[_id] = utcdatetime(value) |
|
1525 elif isinstance(value, time) and value.tzinfo is not None: |
|
1526 self._query_attrs[_id] = utctime(value) |
|
1527 else: |
1517 else: |
1528 _id = str(id(constant)).replace('-', '', 1) |
1518 _id = str(id(constant)).replace('-', '', 1) |
1529 self._query_attrs[_id] = value |
1519 self._query_attrs[_id] = value |
1530 return '%%(%s)s' % _id |
1520 return '%%(%s)s' % _id |
1531 |
1521 |