summary refs log tree commit diff
path: root/synapse/storage/roommember.py
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <paul@matrix.org>2014-12-02 21:36:53 +0000
committerPaul "LeoNerd" Evans <paul@matrix.org>2014-12-02 21:36:53 +0000
commit10eb8f070cc5e4fc5067c98ef699724716e33f74 (patch)
tree51a93d87ebf14fdd1437fcbf982502e54af1e512 /synapse/storage/roommember.py
parentExtra verbosity on logging of received presence info (diff)
downloadsynapse-10eb8f070cc5e4fc5067c98ef699724716e33f74.tar.xz
Workaround for non-uniqueness of room member events in the database confusing HAVING COUNT() test of room membership intersection (with thanks to Tom Molesworth)
Diffstat (limited to 'synapse/storage/roommember.py')
-rw-r--r--synapse/storage/roommember.py4
1 files changed, 3 insertions, 1 deletions
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)