stop dropping tzinfo when specified. Closes #1485893

authorSylvain Thénault <sylvain.thenault@logilab.fr>
changeset0f8c03d2620a
branchdefault
phasedraft
hiddenyes
parent revision#bca353bb8876 [sqlite] don't call abspath is :memory: is given
child revision#0efe4ddb104d make sqlite tz datetime aware
files modified by this revision
logilab/database/__init__.py
# HG changeset patch
# User Sylvain Thénault <sylvain.thenault@logilab.fr>
# Date 1442494324 -7200
# Thu Sep 17 14:52:04 2015 +0200
# Node ID 0f8c03d2620a8cc4296f7929c58bc03af557f4f7
# Parent bca353bb887696fc321b734bf2aa125b802b157b
stop dropping tzinfo when specified. Closes #1485893

diff --git a/logilab/database/__init__.py b/logilab/database/__init__.py
@@ -367,12 +367,10 @@
1              transform = lambda v: unicode(v, encoding, 'replace')
2          elif typecode == self.BOOLEAN:
3              transform = bool
4          elif typecode == self.BINARY and binarywrap is not None:
5              transform = binarywrap
6 -        elif typecode == self.DATETIME: # XXX only for TZDatetime w/ backend returning some tzinfo
7 -            transform = lambda v: utcdatetime(v) if isinstance(v, datetime) else v
8          elif typecode == self.UNKNOWN:
9              # may occurs on constant selection for instance (e.g. SELECT 'hop')
10              # with postgresql at least
11              transform = lambda v: unicode(v, encoding, 'replace') if isinstance(v, str) else v
12          return transform
@@ -424,15 +422,10 @@
13          transform = self._transformation_callback(description,
14                                                    encoding,
15                                                    binarywrap)
16          if transform is not None:
17              value = transform(value)
18 -        elif getattr(value, 'tzinfo', None):
19 -            if isinstance(value, time):
20 -                value = utctime(value)
21 -            assert isinstance(value, datetime), value
22 -            value = utcdatetime(value)
23          return value
24 
25      def binary_to_str(self, value):
26          """turn raw value returned by the db-api module into a python string"""
27          return binary_type(value)