Mercurial > libervia-pubsub
diff src/pgsql_storage.py @ 393:728b08c0d000
storage (pgsql): fixed storage of multiple items
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 15 Feb 2019 22:06:19 +0100 |
parents | fba96e95e329 |
children | 724e39d596a9 |
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