mirror of
https://github.com/element-hq/synapse
synced 2024-09-28 16:32:40 +00:00
Raise a ValueError if keyvalues is falsely
This commit is contained in:
parent
efc492ed99
commit
90128dd355
1 changed files with 11 additions and 4 deletions
|
@ -2108,18 +2108,25 @@ class DatabasePool:
|
|||
) -> int:
|
||||
"""Executes a DELETE query on the named table.
|
||||
|
||||
Filters rows by the key-value pairs.
|
||||
Filter rows by the key-value pairs.
|
||||
|
||||
Args:
|
||||
table: string giving the table name
|
||||
keyvalues: dict of column names and values to select the row with. If empty,
|
||||
no rows will be deleted.
|
||||
keyvalues: dict of column names and values to select the row with. Must
|
||||
not be empty.
|
||||
|
||||
Returns:
|
||||
The number of deleted rows.
|
||||
|
||||
Raises:
|
||||
ValueError: if keyvalues was a falsey value, such as an empty dict.
|
||||
"""
|
||||
if not keyvalues:
|
||||
return 0
|
||||
raise ValueError(
|
||||
"'keyvalues' arg to simple_delete_txn was falsey. If you were trying to "
|
||||
"delete all rows from a database, perhaps try "
|
||||
"DatabasePool.simple_truncate instead?"
|
||||
)
|
||||
|
||||
sql = "DELETE FROM %s WHERE %s" % (
|
||||
table,
|
||||
|
|
Loading…
Reference in a new issue