From 10eb8f070cc5e4fc5067c98ef699724716e33f74 Mon Sep 17 00:00:00 2001 From: "Paul \"LeoNerd\" Evans" Date: Tue, 2 Dec 2014 21:36:53 +0000 Subject: [PATCH] Workaround for non-uniqueness of room member events in the database confusing HAVING COUNT() test of room membership intersection (with thanks to Tom Molesworth) --- synapse/storage/roommember.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/synapse/storage/roommember.py b/synapse/storage/roommember.py index c37df59d45..05b275663e 100644 --- a/synapse/storage/roommember.py +++ b/synapse/storage/roommember.py @@ -218,7 +218,9 @@ class RoomMemberStore(SQLBaseStore): "ON m.event_id = c.event_id " "WHERE m.membership = 'join' " "AND (%(clause)s) " - "GROUP BY m.room_id HAVING COUNT(m.room_id) = ?" + # TODO(paul): We've got duplicate rows in the database somewhere + # so we have to DISTINCT m.user_id here + "GROUP BY m.room_id HAVING COUNT(DISTINCT m.user_id) = ?" ) % {"clause": user_list_clause} args = list(user_id_list)