ensure eid given in arguments will be returned correctly typed (though only if they are in the cachekey for now) stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 08 Sep 2009 10:46:47 +0200
branchstable
changeset 3109 e7e1bb06b716
parent 3108 aa43c0c22b98
child 3112 873202e181bb
ensure eid given in arguments will be returned correctly typed (though only if they are in the cachekey for now)
server/querier.py
server/test/unittest_querier.py
--- a/server/querier.py	Mon Sep 07 20:23:40 2009 +0200
+++ b/server/querier.py	Tue Sep 08 10:46:47 2009 +0200
@@ -608,6 +608,8 @@
                     # return an empty result instead of raising UnknownEid
                     return empty_rset(session, rql, args)
                 cachekey.append(etype)
+                # ensure eid is correctly typed in args
+                args[key] = typed_eid(args[key])
             cachekey = tuple(cachekey)
         else:
             cachekey = rql
--- a/server/test/unittest_querier.py	Mon Sep 07 20:23:40 2009 +0200
+++ b/server/test/unittest_querier.py	Tue Sep 08 10:46:47 2009 +0200
@@ -210,6 +210,11 @@
         # should return an empty result set
         self.failIf(self.execute('Any X WHERE X eid 99999999'))
 
+    def test_typed_eid(self):
+        # should return an empty result set
+        rset = self.execute('Any X WHERE X eid %(x)s', {'x': '1'}, 'x')
+        self.assertIsInstance(rset[0][0], (int, long))
+
     def test_bytes_storage(self):
         feid = self.execute('INSERT File X: X name "foo.pdf", X data_format "text/plain", X data %(data)s',
                             {'data': Binary("xxx")})[0][0]