From 452fc33646cb35b709aa0fc9248209b19f010458 Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Thu, 4 Aug 2022 15:26:59 +0100 Subject: Prevent empty keyvalues arg to simple_delete raising db exception --- synapse/storage/database.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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), -- cgit 1.5.1