[sql] more test and fix boolean handling stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 27 Jul 2011 18:08:39 +0200
branchstable
changeset 7713 467c52ff9557
parent 7712 82c84ca05d6e
child 7714 1e79e63b6dba
[sql] more test and fix boolean handling
server/sources/rql2sql.py
server/test/unittest_querier.py
server/test/unittest_repository.py
--- a/server/sources/rql2sql.py	Wed Jul 27 16:44:02 2011 +0200
+++ b/server/sources/rql2sql.py	Wed Jul 27 18:08:39 2011 +0200
@@ -1494,8 +1494,6 @@
                     self._query_attrs[_id] = utcdatetime(value)
                 elif isinstance(value, time) and value.tzinfo is not None:
                     self._query_attrs[_id] = utctime(value)
-                elif isinstance(value, bool):
-                    return self.dbhelper.boolean_value(value)
         else:
             _id = str(id(constant)).replace('-', '', 1)
             self._query_attrs[_id] = value
--- a/server/test/unittest_querier.py	Wed Jul 27 16:44:02 2011 +0200
+++ b/server/test/unittest_querier.py	Wed Jul 27 18:08:39 2011 +0200
@@ -800,6 +800,12 @@
                                                            'Password', 'String',
                                                            'TZDatetime', 'TZTime',
                                                            'Time'])
+        req = self.session
+        req.create_entity('Personne', nom=u'louis', test=True)
+        self.assertEqual(len(req.execute('Any X WHERE X test %(val)s', {'val': True})), 1)
+        self.assertEqual(len(req.execute('Any X WHERE X test TRUE')), 1)
+        self.assertEqual(len(req.execute('Any X WHERE X test %(val)s', {'val': False})), 0)
+        self.assertEqual(len(req.execute('Any X WHERE X test FALSE')), 0)
 
     def test_select_constant(self):
         rset = self.execute('Any X, "toto" ORDERBY X WHERE X is CWGroup')
--- a/server/test/unittest_repository.py	Wed Jul 27 16:44:02 2011 +0200
+++ b/server/test/unittest_repository.py	Wed Jul 27 18:08:39 2011 +0200
@@ -68,7 +68,7 @@
                 namecol, table, finalcol))
             self.assertEqual(cu.fetchall(), [])
             cu = self.session.system_sql('SELECT %s FROM %s WHERE %s=%%(final)s ORDER BY %s'
-                                         % (namecol, table, finalcol, namecol), {'final': 'TRUE'})
+                                         % (namecol, table, finalcol, namecol), {'final': True})
             self.assertEqual(cu.fetchall(), [(u'BigInt',), (u'Boolean',), (u'Bytes',),
                                              (u'Date',), (u'Datetime',),
                                              (u'Decimal',),(u'Float',),