0
0
Fork 1
mirror of https://mau.dev/maunium/synapse.git synced 2024-11-12 04:52:26 +01:00

build where_clause sanely

This commit is contained in:
Matthew Hodgson 2018-03-13 18:13:44 +00:00
parent 52f7e23c72
commit b2aba9e430

View file

@ -263,18 +263,16 @@ class StateGroupWorkerStore(SQLBaseStore):
results[group][key] = event_id results[group][key] = event_id
else: else:
where_args = [] where_args = []
where_clauses = []
if types is not None: if types is not None:
where_clause = "AND ("
for typ in types: for typ in types:
if typ[1] is None: if typ[1] is None:
where_clause += "(type = ?)" where_clauses.append("(type = ?)")
where_args.extend(typ[0]) where_args.extend(typ[0])
else: else:
where_clause += "(type = ? AND state_key = ?)" where_clauses.append("(type = ? AND state_key = ?)")
where_args.extend([typ[0], typ[1]]) where_args.extend([typ[0], typ[1]])
if typ != types[-1]: where_clause = "AND (%s)" % (" OR ".join(where_clauses))
where_clause += " OR "
where_clause += ")"
else: else:
where_clause = "" where_clause = ""