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

Commit c9fa696

Browse files
authored
simple_search_list_txn should return None, not 0. (#8187)
1 parent 5649b7f commit c9fa696

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

changelog.d/8187.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add type hints to `synapse.storage.database`.

synapse/storage/database.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
Optional,
2929
Tuple,
3030
TypeVar,
31-
Union,
3231
overload,
3332
)
3433

@@ -1655,7 +1654,7 @@ def simple_search_list_txn(
16551654
term: Optional[str],
16561655
col: str,
16571656
retcols: Iterable[str],
1658-
) -> Union[List[Dict[str, Any]], int]:
1657+
) -> Optional[List[Dict[str, Any]]]:
16591658
"""Executes a SELECT query on the named table, which may return zero or
16601659
more rows, returning the result as a list of dicts.
16611660
@@ -1667,14 +1666,14 @@ def simple_search_list_txn(
16671666
retcols: the names of the columns to return
16681667
16691668
Returns:
1670-
0 if no term is given, otherwise a list of dictionaries.
1669+
None if no term is given, otherwise a list of dictionaries.
16711670
"""
16721671
if term:
16731672
sql = "SELECT %s FROM %s WHERE %s LIKE ?" % (", ".join(retcols), table, col)
16741673
termvalues = ["%%" + term + "%%"]
16751674
txn.execute(sql, termvalues)
16761675
else:
1677-
return 0
1676+
return None
16781677

16791678
return cls.cursor_to_dict(txn)
16801679

0 commit comments

Comments
 (0)