summary refs log tree commit diff
path: root/synapse/storage/_base.py
diff options
context:
space:
mode:
authorRichard van der Hoff <github@rvanderhoff.org.uk>2017-11-27 12:25:48 +0000
committerGitHub <noreply@github.com>2017-11-27 12:25:48 +0000
commit5a4da5bf784669e0b0263279b7a0b0804026348f (patch)
treed8d9d2597243e1304bee0fe6e80e4c5aaf0710a0 /synapse/storage/_base.py
parentMerge pull request #2713 from matrix-org/rav/no_upsert_forever (diff)
parentfix sql fails (diff)
downloadsynapse-5a4da5bf784669e0b0263279b7a0b0804026348f.tar.xz
Merge pull request #2697 from matrix-org/rav/fix_urlcache_index_error
Fix error on sqlite 3.7
Diffstat (limited to 'synapse/storage/_base.py')
-rw-r--r--synapse/storage/_base.py16
1 files changed, 7 insertions, 9 deletions
diff --git a/synapse/storage/_base.py b/synapse/storage/_base.py
index 662c30187d..20fa25895d 100644
--- a/synapse/storage/_base.py
+++ b/synapse/storage/_base.py
@@ -607,20 +607,18 @@ class SQLBaseStore(object):
 
     @staticmethod
     def _simple_select_onecol_txn(txn, table, keyvalues, retcol):
-        if keyvalues:
-            where = "WHERE %s" % " AND ".join("%s = ?" % k for k in keyvalues.iterkeys())
-        else:
-            where = ""
-
         sql = (
-            "SELECT %(retcol)s FROM %(table)s %(where)s"
+            "SELECT %(retcol)s FROM %(table)s"
         ) % {
             "retcol": retcol,
             "table": table,
-            "where": where,
         }
 
-        txn.execute(sql, keyvalues.values())
+        if keyvalues:
+            sql += " WHERE %s" % " AND ".join("%s = ?" % k for k in keyvalues.iterkeys())
+            txn.execute(sql, keyvalues.values())
+        else:
+            txn.execute(sql)
 
         return [r[0] for r in txn]
 
@@ -631,7 +629,7 @@ class SQLBaseStore(object):
 
         Args:
             table (str): table name
-            keyvalues (dict): column names and values to select the rows with
+            keyvalues (dict|None): column names and values to select the rows with
             retcol (str): column whos value we wish to retrieve.
 
         Returns: