summary refs log tree commit diff
path: root/synapse/storage/_base.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-03-02 13:39:22 +0000
committerErik Johnston <erik@matrix.org>2015-03-02 13:39:22 +0000
commit4195e55ccc0f5751b13136b8c5f60686a902b79d (patch)
treed9e1596e1ecf6cfd6a3e7152a20748496a9e0890 /synapse/storage/_base.py
parentUse contextlib.contextmanager instead of a custom class (diff)
parentMerge pull request #95 from matrix-org/serialize_transaction_processing (diff)
downloadsynapse-4195e55ccc0f5751b13136b8c5f60686a902b79d.tar.xz
Merge branch 'develop' of github.com:matrix-org/synapse into federation_rate_limit
Diffstat (limited to 'synapse/storage/_base.py')
-rw-r--r--synapse/storage/_base.py22
1 files changed, 15 insertions, 7 deletions
diff --git a/synapse/storage/_base.py b/synapse/storage/_base.py
index c98dd36aed..3725c9795d 100644
--- a/synapse/storage/_base.py
+++ b/synapse/storage/_base.py
@@ -450,7 +450,8 @@ class SQLBaseStore(object):
 
         Args:
             table : string giving the table name
-            keyvalues : dict of column names and values to select the rows with
+            keyvalues : dict of column names and values to select the rows with,
+            or None to not apply a WHERE clause.
             retcols : list of strings giving the names of the columns to return
         """
         return self.runInteraction(
@@ -469,13 +470,20 @@ 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
         """
-        sql = "SELECT %s FROM %s WHERE %s ORDER BY rowid asc" % (
-            ", ".join(retcols),
-            table,
-            " AND ".join("%s = ?" % (k, ) for k in keyvalues)
-        )
+        if keyvalues:
+            sql = "SELECT %s FROM %s WHERE %s ORDER BY rowid asc" % (
+                ", ".join(retcols),
+                table,
+                " AND ".join("%s = ?" % (k, ) for k in keyvalues)
+            )
+            txn.execute(sql, keyvalues.values())
+        else:
+            sql = "SELECT %s FROM %s ORDER BY rowid asc" % (
+                ", ".join(retcols),
+                table
+            )
+            txn.execute(sql)
 
-        txn.execute(sql, keyvalues.values())
         return self.cursor_to_dict(txn)
 
     def _simple_update_one(self, table, keyvalues, updatevalues,