From 759f9c09e1b2019b772f6baf6a40e74f79df9017 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Wed, 25 May 2022 07:49:54 -0400 Subject: Fix caching behavior for relations push rules. (#12859) By always returning all requested values from the function wrapped by cachedList. Otherwise implicit None values get added into the cache, which are unexpected. --- synapse/storage/databases/main/relations.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'synapse/storage/databases/main/relations.py') diff --git a/synapse/storage/databases/main/relations.py b/synapse/storage/databases/main/relations.py index 3b1b2ce6cb..b457bc189e 100644 --- a/synapse/storage/databases/main/relations.py +++ b/synapse/storage/databases/main/relations.py @@ -13,7 +13,6 @@ # limitations under the License. import logging -from collections import defaultdict from typing import ( Collection, Dict, @@ -810,7 +809,9 @@ class RelationsWorkerStore(SQLBaseStore): txn: LoggingTransaction, ) -> Dict[str, Set[Tuple[str, str]]]: txn.execute(sql, [event_id] + rel_type_args) - result = defaultdict(set) + result: Dict[str, Set[Tuple[str, str]]] = { + rel_type: set() for rel_type in relation_types + } for rel_type, sender, type in txn.fetchall(): result[rel_type].add((sender, type)) return result -- cgit 1.5.1