changeset 2209:ea41cf1e6d29

memory (persistent, sqlite): fixed getPrivates bug with keys arguments and its use in LazyPersistentBinaryDict
author Goffi <goffi@goffi.org>
date Wed, 29 Mar 2017 19:27:52 +0200
parents c316c6f6a737
children f8d61592f1fc
files src/memory/persistent.py src/memory/sqlite.py
diffstat 2 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/memory/persistent.py	Sun Mar 26 21:23:03 2017 +0200
+++ b/src/memory/persistent.py	Wed Mar 29 19:27:52 2017 +0200
@@ -201,7 +201,9 @@
 
     def __getitem__(self, key):
         """get the value as a Deferred"""
-        return self.storage.getPrivates(self.namespace, keys=[key], binary=self.binary, profile=self.profile)
+        d = self.storage.getPrivates(self.namespace, keys=[key], binary=self.binary, profile=self.profile)
+        d.addCallback(lambda data: data[key])
+        return d
 
     def __setitem__(self, key, value):
         self.storage.setPrivateValue(self.namespace, key, value, self.binary, self.profile)
--- a/src/memory/sqlite.py	Sun Mar 26 21:23:03 2017 +0200
+++ b/src/memory/sqlite.py	Wed Mar 29 19:27:52 2017 +0200
@@ -571,8 +571,9 @@
         args = [namespace]
 
         if keys is not None:
-            query_parts.append(u'AND key IN ?')
-            args.append(keys)
+            placeholders = u','.join(len(keys) * u'?')
+            query_parts.append(u'AND key IN (' + placeholders + u')')
+            args.extend(keys)
 
         if profile is not None:
             query_parts.append(u'AND profile_id=?')