stop dropping tzinfo attribute on datetime objects (closes #1485893)

authorSylvain Thénault <sylvain.thenault@logilab.fr>
changeset0187bf306d97
branchdefault
phasepublic
hiddenno
parent revision#5e3b2722ec81 Added tag 1.14.1, debian/1.14.1-1, centos/1.14.1-1 for changeset 92001ea23990
child revision#b639b12aaf38 [sqlite] add support for tz-aware datetime (closes #2777713)
files modified by this revision
debian/control
logilab/database/__init__.py
python-logilab-database.spec
# HG changeset patch
# User Sylvain Thénault <sylvain.thenault@logilab.fr>
# Date 1442494324 -7200
# Thu Sep 17 14:52:04 2015 +0200
# Node ID 0187bf306d978097e6b2f05a6b4d600f893f5b34
# Parent 5e3b2722ec81c608e7f649a10cbd653c50053171
stop dropping tzinfo attribute on datetime objects (closes #1485893)

diff --git a/debian/control b/debian/control
@@ -22,11 +22,12 @@
1  Depends:
2   ${python:Depends},
3   ${misc:Depends},
4   python-logilab-common (>= 0.63.2),
5   python-six (>= 1.4.0),
6 -Conflicts: cubicweb-server (<= 3.9.0)
7 +Breaks:
8 + cubicweb-server (<< 3.22.0),
9  Description: true unified databases access
10   logilab-database provides some classes to make unified access
11   to different RDBMS possible:
12   .
13    * actually compatible db-api from different drivers
diff --git a/logilab/database/__init__.py b/logilab/database/__init__.py
@@ -367,12 +367,10 @@
14              transform = lambda v: unicode(v, encoding, 'replace')
15          elif typecode == self.BOOLEAN:
16              transform = bool
17          elif typecode == self.BINARY and binarywrap is not None:
18              transform = binarywrap
19 -        elif typecode == self.DATETIME: # XXX only for TZDatetime w/ backend returning some tzinfo
20 -            transform = lambda v: utcdatetime(v) if isinstance(v, datetime) else v
21          elif typecode == self.UNKNOWN:
22              # may occurs on constant selection for instance (e.g. SELECT 'hop')
23              # with postgresql at least
24              transform = lambda v: unicode(v, encoding, 'replace') if isinstance(v, str) else v
25          return transform
@@ -424,15 +422,10 @@
26          transform = self._transformation_callback(description,
27                                                    encoding,
28                                                    binarywrap)
29          if transform is not None:
30              value = transform(value)
31 -        elif getattr(value, 'tzinfo', None):
32 -            if isinstance(value, time):
33 -                value = utctime(value)
34 -            assert isinstance(value, datetime), value
35 -            value = utcdatetime(value)
36          return value
37 
38      def binary_to_str(self, value):
39          """turn raw value returned by the db-api module into a python string"""
40          return binary_type(value)
diff --git a/python-logilab-database.spec b/python-logilab-database.spec
@@ -25,10 +25,11 @@
41  Requires:       %{python}
42  Requires:       %{python}-setuptools
43  Requires:       %{python}-logilab-common >= 0.63.2
44  Requires:       %{python}-six >= 1.4.0
45  Requires:       %{python}-yapps2 >= 2.1.1
46 +Conflicts:      cubicweb < 3.22.0
47 
48 
49  %description
50  logilab-database provides some classes to make unified access
51  to different RDBMS possible: