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 |
53 from datetime import datetime, time |
|
54 |
|
55 from logilab.common.date import utcdatetime, utctime |
54 from logilab.database import FunctionDescr, SQL_FUNCTIONS_REGISTRY |
56 from logilab.database import FunctionDescr, SQL_FUNCTIONS_REGISTRY |
55 |
57 |
56 from rql import BadRQLQuery, CoercionError |
58 from rql import BadRQLQuery, CoercionError |
57 from rql.stmts import Union, Select |
59 from rql.stmts import Union, Select |
58 from rql.nodes import (SortTerm, VariableRef, Constant, Function, Variable, Or, |
60 from rql.nodes import (SortTerm, VariableRef, Constant, Function, Variable, Or, |
1169 return self._mapped_term(constant, '%%(%s)s' % value)[0] |
1171 return self._mapped_term(constant, '%%(%s)s' % value)[0] |
1170 except KeyError: |
1172 except KeyError: |
1171 _id = value |
1173 _id = value |
1172 if isinstance(_id, unicode): |
1174 if isinstance(_id, unicode): |
1173 _id = _id.encode() |
1175 _id = _id.encode() |
|
1176 # convert timestamp to utc. |
|
1177 # expect SET TiME ZONE to UTC at connection opening time. |
|
1178 # This shouldn't change anything for datetime without TZ. |
|
1179 value = self._args[_id] |
|
1180 if isinstance(value, datetime) and value.tzinfo is not None: |
|
1181 self._query_attrs[_id] = utcdatetime(value) |
|
1182 elif isinstance(value, time) and value.tzinfo is not None: |
|
1183 self._query_attrs[_id] = utctime(value) |
1174 else: |
1184 else: |
1175 _id = str(id(constant)).replace('-', '', 1) |
1185 _id = str(id(constant)).replace('-', '', 1) |
1176 self._query_attrs[_id] = value |
1186 self._query_attrs[_id] = value |
1177 return '%%(%s)s' % _id |
1187 return '%%(%s)s' % _id |
1178 |
1188 |