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.
This commit is contained in:
Patrick Cloke 2022-05-25 07:49:54 -04:00 committed by GitHub
parent 4cbcd4a999
commit 759f9c09e1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 9 deletions

View file

@ -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