summary refs log tree commit diff
path: root/synapse/storage/search.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2019-10-02 19:07:07 +0100
committerErik Johnston <erik@matrix.org>2019-10-10 13:15:49 +0100
commitb161786c1455f219d58549b514f2551f25eae33a (patch)
tree4d4ec7936df2a3295c6d57c8cbb0001b34cf9aa6 /synapse/storage/search.py
parentAdd helper funcs to use postgres ANY (diff)
downloadsynapse-b161786c1455f219d58549b514f2551f25eae33a.tar.xz
Replace IN usage with helper funcs
Diffstat (limited to 'synapse/storage/search.py')
-rw-r--r--synapse/storage/search.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/synapse/storage/search.py b/synapse/storage/search.py

index 6ba4190f1a..4be6e56dfa 100644 --- a/synapse/storage/search.py +++ b/synapse/storage/search.py
@@ -24,6 +24,7 @@ from canonicaljson import json from twisted.internet import defer from synapse.api.errors import SynapseError +from synapse.storage._base import add_in_list_sql_clause from synapse.storage.engines import PostgresEngine, Sqlite3Engine from .background_updates import BackgroundUpdateStore @@ -385,8 +386,9 @@ class SearchStore(SearchBackgroundUpdateStore): # Make sure we don't explode because the person is in too many rooms. # We filter the results below regardless. if len(room_ids) < 500: - clauses.append("room_id IN (%s)" % (",".join(["?"] * len(room_ids)),)) - args.extend(room_ids) + add_in_list_sql_clause( + self.database_engine, "room_id", room_ids, clauses, args + ) local_clauses = [] for key in keys: @@ -492,8 +494,9 @@ class SearchStore(SearchBackgroundUpdateStore): # Make sure we don't explode because the person is in too many rooms. # We filter the results below regardless. if len(room_ids) < 500: - clauses.append("room_id IN (%s)" % (",".join(["?"] * len(room_ids)),)) - args.extend(room_ids) + add_in_list_sql_clause( + self.database_engine, "room_id", room_ids, clauses, args + ) local_clauses = [] for key in keys: