summary refs log tree commit diff
diff options
context:
space:
mode:
authorPatrick Cloke <clokep@users.noreply.github.com>2020-08-27 12:07:13 -0400
committerGitHub <noreply@github.com>2020-08-27 12:07:13 -0400
commitc9fa696ea2ad5bc32430aeb1bc555df537a71a59 (patch)
tree750186b5fe88c21e5d501b47f704fcd711a47198
parentFix missing _add_persisted_position (#8179) (diff)
downloadsynapse-c9fa696ea2ad5bc32430aeb1bc555df537a71a59.tar.xz
simple_search_list_txn should return None, not 0. (#8187)
-rw-r--r--changelog.d/8187.misc1
-rw-r--r--synapse/storage/database.py7
2 files changed, 4 insertions, 4 deletions
diff --git a/changelog.d/8187.misc b/changelog.d/8187.misc
new file mode 100644
index 0000000000..cb557122aa
--- /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 2f6f49a4bf..ba4c0c9af6 100644
--- a/synapse/storage/database.py
+++ b/synapse/storage/database.py
@@ -28,7 +28,6 @@ from typing import (
     Optional,
     Tuple,
     TypeVar,
-    Union,
     overload,
 )
 
@@ -1655,7 +1654,7 @@ class DatabasePool(object):
         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 @@ class DatabasePool(object):
             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)