changeset 393:728b08c0d000

storage (pgsql): fixed storage of multiple items
author Goffi <goffi@goffi.org>
date Fri, 15 Feb 2019 22:06:19 +0100
parents 3fb2ff438f09
children dc83b1d837cf
files src/pgsql_storage.py
diffstat 1 files changed, 11 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/pgsql_storage.py	Fri Feb 15 18:05:31 2019 +0100
+++ b/src/pgsql_storage.py	Fri Feb 15 22:06:19 2019 +0100
@@ -857,13 +857,19 @@
 
         return u"ORDER BY " + u",".join([col for col in cols_statmnt])
 
-    def storeItems(self, item_data, publisher):
-        return self.dbpool.runInteraction(self._storeItems, item_data, publisher)
+    @defer.inlineCallbacks
+    def storeItems(self, items_data, publisher):
+        # XXX: runInteraction doesn't seem to work when there are several "insert"
+        #      or "update".
+        #      Before the unpacking was done in _storeItems, but this was causing trouble
+        #      in case of multiple items_data. So this has now be moved here.
+        # FIXME: investigate the issue with runInteraction
+        for item_data in items_data:
+            yield self.dbpool.runInteraction(self._storeItems, item_data, publisher)
 
-    def _storeItems(self, cursor, items_data, publisher):
+    def _storeItems(self, cursor, item_data, publisher):
         self._checkNodeExists(cursor)
-        for item_data in items_data:
-            self._storeItem(cursor, item_data, publisher)
+        self._storeItem(cursor, item_data, publisher)
 
     def _storeItem(self, cursor, item_data, publisher):
         # first try to insert the item