diff options
author | Erik Johnston <erikj@jki.re> | 2019-03-14 13:54:15 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-14 13:54:15 +0000 |
commit | 9073cfc8bda9b2c37b0ac8b428db39b3580cd18a (patch) | |
tree | ecedb9b87e11e269b2fdf009ecdcd7c3985a2e80 /synapse/storage/_base.py | |
parent | Document using a certificate with a full chain (#4849) (diff) | |
parent | fixup (diff) | |
download | synapse-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.py | 13 |
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())) |