--- a/server/sqlutils.py Mon Sep 14 11:15:47 2015 +0200
+++ b/server/sqlutils.py Mon Oct 12 10:53:35 2015 +0200
@@ -21,11 +21,11 @@
__docformat__ = "restructuredtext en"
import sys
-import os
import re
import subprocess
from os.path import abspath
from logging import getLogger
+from datetime import time, datetime
from six import string_types
from six.moves import filter
@@ -34,6 +34,7 @@
from logilab.common.shellutils import ProgressBar, DummyProgressBar
from logilab.common.deprecation import deprecated
from logilab.common.logging_ext import set_log_methods
+from logilab.common.date import utctime, utcdatetime
from logilab.database.sqlgen import SQLGenerator
from cubicweb import Binary, ConfigurationError
@@ -376,8 +377,17 @@
# convert cubicweb binary into db binary
if isinstance(val, Binary):
val = self._binary(val.getvalue())
+ # convert timestamp to utc.
+ # expect SET TiME ZONE to UTC at connection opening time.
+ # This shouldn't change anything for datetime without TZ.
+ elif isinstance(val, datetime) and val.tzinfo is not None:
+ val = utcdatetime(val)
+ elif isinstance(val, time) and val.tzinfo is not None:
+ val = utctime(val)
newargs[key] = val
# should not collide
+ assert not (frozenset(newargs) & frozenset(query_args)), \
+ 'unexpected collision: %s' % (frozenset(newargs) & frozenset(query_args))
newargs.update(query_args)
return newargs
return query_args