diff options
author | Amber Brown <hawkowl@atleastfornow.net> | 2019-03-12 00:35:31 +1100 |
---|---|---|
committer | Amber Brown <hawkowl@atleastfornow.net> | 2019-03-12 00:35:31 +1100 |
commit | 5ba8ceab4cd7062d9f1b23a19d43f8a9ef7c5d60 (patch) | |
tree | 4211360bb8a8da013f2cc1383c42c94e86c954d9 /synapse/storage/_base.py | |
parent | setup master (diff) | |
download | synapse-5ba8ceab4cd7062d9f1b23a19d43f8a9ef7c5d60.tar.xz |
fixes
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())) |