Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

simple_search_list_txn should return None, not 0. #8187

Merged
merged 1 commit into from
Aug 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/8187.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add type hints to `synapse.storage.database`.
7 changes: 3 additions & 4 deletions synapse/storage/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
Optional,
Tuple,
TypeVar,
Union,
overload,
)

Expand Down Expand Up @@ -1655,7 +1654,7 @@ def simple_search_list_txn(
term: Optional[str],
col: str,
retcols: Iterable[str],
) -> Union[List[Dict[str, Any]], int]:
) -> Optional[List[Dict[str, Any]]]:
"""Executes a SELECT query on the named table, which may return zero or
more rows, returning the result as a list of dicts.

Expand All @@ -1667,14 +1666,14 @@ def simple_search_list_txn(
retcols: the names of the columns to return

Returns:
0 if no term is given, otherwise a list of dictionaries.
None if no term is given, otherwise a list of dictionaries.
"""
if term:
sql = "SELECT %s FROM %s WHERE %s LIKE ?" % (", ".join(retcols), table, col)
termvalues = ["%%" + term + "%%"]
txn.execute(sql, termvalues)
else:
return 0
return None

return cls.cursor_to_dict(txn)

Expand Down