summary refs log tree commit diff
path: root/synapse/storage
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2016-01-25 15:59:29 +0000
committerErik Johnston <erik@matrix.org>2016-01-25 15:59:29 +0000
commitaea5da0ef6f4d3907ace2c1fdba743312118660c (patch)
treef1b613139810b2c0f6d39d130eeb0a4cbe7b3cd1 /synapse/storage
parentCorrect docstring (diff)
downloadsynapse-aea5da0ef6f4d3907ace2c1fdba743312118660c.tar.xz
Guard against empty iterables
Diffstat (limited to 'synapse/storage')
-rw-r--r--synapse/storage/_base.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/synapse/storage/_base.py b/synapse/storage/_base.py
index 304ebdc825..90d7aee94a 100644
--- a/synapse/storage/_base.py
+++ b/synapse/storage/_base.py
@@ -647,6 +647,9 @@ class SQLBaseStore(object):
         """
         results = []
 
+        if not iterable:
+            defer.returnValue(results)
+
         chunks = [iterable[i:i+batch_size] for i in xrange(0, len(iterable), batch_size)]
         for chunk in chunks:
             rows = yield self.runInteraction(
@@ -673,6 +676,9 @@ class SQLBaseStore(object):
             keyvalues : dict of column names and values to select the rows with
             retcols : list of strings giving the names of the columns to return
         """
+        if not iterable:
+            return []
+
         sql = "SELECT %s FROM %s" % (", ".join(retcols), table)
 
         clauses = []