From c818aa13eb47c9d30da26645850a2af2672edf68 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Thu, 25 Sep 2014 15:51:21 +0100 Subject: [PATCH] Add LIMIT to scalar subquery --- synapse/storage/__init__.py | 3 ++- synapse/storage/roommember.py | 3 ++- synapse/storage/stream.py | 9 ++++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/synapse/storage/__init__.py b/synapse/storage/__init__.py index fcf8b4d18..38f5ec0ac 100644 --- a/synapse/storage/__init__.py +++ b/synapse/storage/__init__.py @@ -255,7 +255,8 @@ class DataStore(RoomMemberStore, RoomStore, @defer.inlineCallbacks def get_current_state(self, room_id, event_type=None, state_key=""): del_sql = ( - "SELECT event_id FROM redactions WHERE redacts = e.event_id" + "SELECT event_id FROM redactions WHERE redacts = e.event_id " + "LIMIT 1" ) sql = ( diff --git a/synapse/storage/roommember.py b/synapse/storage/roommember.py index 84c462330..958e73059 100644 --- a/synapse/storage/roommember.py +++ b/synapse/storage/roommember.py @@ -183,7 +183,8 @@ class RoomMemberStore(SQLBaseStore): def _get_members_query_txn(self, txn, where_clause, where_values): del_sql = ( - "SELECT event_id FROM redactions WHERE redacts = e.event_id" + "SELECT event_id FROM redactions WHERE redacts = e.event_id " + "LIMIT 1" ) sql = ( diff --git a/synapse/storage/stream.py b/synapse/storage/stream.py index 91baa1831..d61f90993 100644 --- a/synapse/storage/stream.py +++ b/synapse/storage/stream.py @@ -158,7 +158,8 @@ class StreamStore(SQLBaseStore): ) del_sql = ( - "SELECT event_id FROM redactions WHERE redacts = e.event_id" + "SELECT event_id FROM redactions WHERE redacts = e.event_id " + "LIMIT 1" ) if limit: @@ -230,7 +231,8 @@ class StreamStore(SQLBaseStore): limit_str = "" del_sql = ( - "SELECT event_id FROM redactions WHERE redacts = events.event_id" + "SELECT event_id FROM redactions WHERE redacts = events.event_id " + "LIMIT 1" ) sql = ( @@ -272,7 +274,8 @@ class StreamStore(SQLBaseStore): # TODO (erikj): Handle compressed feedback del_sql = ( - "SELECT event_id FROM redactions WHERE redacts = events.event_id" + "SELECT event_id FROM redactions WHERE redacts = events.event_id " + "LIMIT 1" ) sql = (