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

Commit

Permalink
simple_search_list_txn should return None, not 0. (#8187)
Browse files Browse the repository at this point in the history
  • Loading branch information
clokep authored Aug 27, 2020
1 parent 5649b7f commit c9fa696
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
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

0 comments on commit c9fa696

Please sign in to comment.