# HG changeset patch # User Sylvain Thénault # Date 1450427835 -3600 # Node ID 38afb7e23c6ca1293548e5cf8ecf923d3a5a2082 # Parent 780939fc06da7616bd54565eba5a482f460973b1 [server] fix SQLite patch to ensure TZDatetime are properly typed NB: at this point, the TZ info is completely ignored. It will be properly handled in later commits. diff -r 780939fc06da -r 38afb7e23c6c server/sqlutils.py --- a/server/sqlutils.py Fri Dec 18 09:10:20 2015 +0100 +++ b/server/sqlutils.py Fri Dec 18 09:37:15 2015 +0100 @@ -495,7 +495,8 @@ found_date = False for row, rowdesc in zip(rset, rset.description): for cellindex, (value, vtype) in enumerate(zip(row, rowdesc)): - if vtype in ('Date', 'Datetime') and isinstance(value, text_type): + if vtype in ('TZDatetime', 'Date', 'Datetime') \ + and isinstance(value, text_type): found_date = True value = value.rsplit('.', 1)[0] try: diff -r 780939fc06da -r 38afb7e23c6c server/test/unittest_querier.py --- a/server/test/unittest_querier.py Fri Dec 18 09:10:20 2015 +0100 +++ b/server/test/unittest_querier.py Fri Dec 18 09:37:15 2015 +0100 @@ -847,7 +847,13 @@ self.assertIsInstance(rset.rows[0][0], datetime) rset = self.qexecute('Tag X WHERE X creation_date TODAY') self.assertEqual(len(rset.rows), 2) - rset = self.qexecute('Any MAX(D) WHERE X is Tag, X creation_date D') + + def test_sqlite_patch(self): + """this test monkey patch done by sqlutils._install_sqlite_querier_patch""" + self.qexecute("INSERT Personne X: X nom 'bidule', X datenaiss NOW, X tzdatenaiss NOW") + rset = self.qexecute('Any MAX(D) WHERE X is Personne, X datenaiss D') + self.assertIsInstance(rset[0][0], datetime) + rset = self.qexecute('Any MAX(D) WHERE X is Personne, X tzdatenaiss D') self.assertIsInstance(rset[0][0], datetime) def test_today(self):