summary refs log tree commit diff
path: root/synapse/storage/_base.py
diff options
context:
space:
mode:
authorErik Johnston <erikj@jki.re>2019-03-14 13:54:15 +0000
committerGitHub <noreply@github.com>2019-03-14 13:54:15 +0000
commit9073cfc8bda9b2c37b0ac8b428db39b3580cd18a (patch)
treeecedb9b87e11e269b2fdf009ecdcd7c3985a2e80 /synapse/storage/_base.py
parentDocument using a certificate with a full chain (#4849) (diff)
parentfixup (diff)
downloadsynapse-9073cfc8bda9b2c37b0ac8b428db39b3580cd18a.tar.xz
Merge pull request #4846 from matrix-org/hawkowl/userdir-search
Improve searching in the userdir
Diffstat (limited to 'synapse/storage/_base.py')
-rw-r--r--synapse/storage/_base.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/synapse/storage/_base.py b/synapse/storage/_base.py
index a0333d5309..7e3903859b 100644
--- a/synapse/storage/_base.py
+++ b/synapse/storage/_base.py
@@ -767,18 +767,25 @@ class SQLBaseStore(object):
         """
         allvalues = {}
         allvalues.update(keyvalues)
-        allvalues.update(values)
         allvalues.update(insertion_values)
 
+        if not values:
+            latter = "NOTHING"
+        else:
+            allvalues.update(values)
+            latter = (
+                "UPDATE SET " + ", ".join(k + "=EXCLUDED." + k for k in values)
+            )
+
         sql = (
             "INSERT INTO %s (%s) VALUES (%s) "
-            "ON CONFLICT (%s) DO UPDATE SET %s"
+            "ON CONFLICT (%s) DO %s"
         ) % (
             table,
             ", ".join(k for k in allvalues),
             ", ".join("?" for _ in allvalues),
             ", ".join(k for k in keyvalues),
-            ", ".join(k + "=EXCLUDED." + k for k in values),
+            latter
         )
         txn.execute(sql, list(allvalues.values()))