From d4aec2554c20b6a338b8c8bbf9eab879d75be65e Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Thu, 27 Aug 2020 08:35:49 -0400 Subject: [PATCH] simple_search_list_txn should return None, not 0. --- changelog.d/8187.misc | 1 + synapse/storage/database.py | 7 +++---- 2 files changed, 4 insertions(+), 4 deletions(-) create mode 100644 changelog.d/8187.misc diff --git a/changelog.d/8187.misc b/changelog.d/8187.misc new file mode 100644 index 000000000000..cb557122aaa1 --- /dev/null +++ b/changelog.d/8187.misc @@ -0,0 +1 @@ +Add type hints to `synapse.storage.database`. diff --git a/synapse/storage/database.py b/synapse/storage/database.py index 2f6f49a4bf84..ba4c0c9af6d1 100644 --- a/synapse/storage/database.py +++ b/synapse/storage/database.py @@ -28,7 +28,6 @@ Optional, Tuple, TypeVar, - Union, overload, ) @@ -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. @@ -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)