diff options
author | Andrew Morgan <andrewm@element.io> | 2022-08-04 15:26:59 +0100 |
---|---|---|
committer | Andrew Morgan <andrewm@element.io> | 2022-08-04 15:26:59 +0100 |
commit | 452fc33646cb35b709aa0fc9248209b19f010458 (patch) | |
tree | a8058840c9395635a5db11a10083c42e18b736f0 | |
parent | Add a test for simple_truncate (diff) | |
download | synapse-452fc33646cb35b709aa0fc9248209b19f010458.tar.xz |
Prevent empty keyvalues arg to simple_delete raising db exception
-rw-r--r-- | synapse/storage/database.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/synapse/storage/database.py b/synapse/storage/database.py index 4b62ffbb5a..396d09ac4f 100644 --- a/synapse/storage/database.py +++ b/synapse/storage/database.py @@ -2112,11 +2112,15 @@ class DatabasePool: Args: table: string giving the table name - keyvalues: dict of column names and values to select the row with + keyvalues: dict of column names and values to select the row with. If empty, + no rows will be deleted. Returns: The number of deleted rows. """ + if not keyvalues: + return 0 + sql = "DELETE FROM %s WHERE %s" % ( table, " AND ".join("%s = ?" % (k,) for k in keyvalues), |