summary refs log tree commit diff
path: root/synapse/storage/events.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2019-09-09 13:33:38 +0100
committerErik Johnston <erik@matrix.org>2019-09-09 13:33:38 +0100
commite7184a437062ae21846b8e071ded73526209e90c (patch)
treecc47b2b3477daadfb7c19bd92b7f4dde59425198 /synapse/storage/events.py
parentFixup comment (diff)
downloadsynapse-e7184a437062ae21846b8e071ded73526209e90c.tar.xz
Use better names in SQL
Diffstat (limited to '')
-rw-r--r--synapse/storage/events.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/synapse/storage/events.py b/synapse/storage/events.py
index 4484ae7ce0..0da6e0b1a1 100644
--- a/synapse/storage/events.py
+++ b/synapse/storage/events.py
@@ -1586,12 +1586,15 @@ class EventsStore(
         # We use the range [-max_pos, max_pos] to handle backfilled events,
         # which are given negative stream ordering.
         sql = """
-            SELECT er.event_id, redacts FROM redactions
-            INNER JOIN events AS er USING (event_id)
-            INNER JOIN events AS eb ON (er.room_id = eb.room_id AND redacts = eb.event_id)
+            SELECT redact_event.event_id, redacts FROM redactions
+            INNER JOIN events AS redact_event USING (event_id)
+            INNER JOIN events AS original_event ON (
+                redact_event.room_id = original_event.room_id
+                AND redacts = original_event.event_id
+            )
             WHERE NOT have_censored
-            AND ? <= er.stream_ordering AND er.stream_ordering <= ?
-            ORDER BY er.stream_ordering ASC
+            AND ? <= redact_event.stream_ordering AND redact_event.stream_ordering <= ?
+            ORDER BY redact_event.stream_ordering ASC
             LIMIT ?
         """