mirror of
https://github.com/element-hq/synapse
synced 2024-10-01 07:32:41 +00:00
Prevent empty keyvalues arg to simple_delete raising db exception
This commit is contained in:
parent
1777a21d12
commit
452fc33646
1 changed files with 5 additions and 1 deletions
|
@ -2112,11 +2112,15 @@ class DatabasePool:
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
table: string giving the table name
|
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:
|
Returns:
|
||||||
The number of deleted rows.
|
The number of deleted rows.
|
||||||
"""
|
"""
|
||||||
|
if not keyvalues:
|
||||||
|
return 0
|
||||||
|
|
||||||
sql = "DELETE FROM %s WHERE %s" % (
|
sql = "DELETE FROM %s WHERE %s" % (
|
||||||
table,
|
table,
|
||||||
" AND ".join("%s = ?" % (k,) for k in keyvalues),
|
" AND ".join("%s = ?" % (k,) for k in keyvalues),
|
||||||
|
|
Loading…
Reference in a new issue