diff options
author | Mark Haines <mark.haines@matrix.org> | 2015-04-30 16:54:55 +0100 |
---|---|---|
committer | Mark Haines <mark.haines@matrix.org> | 2015-04-30 16:54:55 +0100 |
commit | 2d4d2bbae4f35e3128fa492e45cfc5b0750524bc (patch) | |
tree | 8e3fa03a60443dc2a1af80d5fb13aa0e28ffddca /synapse/storage/state.py | |
parent | Write a default log_config when generating config (diff) | |
parent | Add get_rooms_for_user cache (diff) | |
download | synapse-2d4d2bbae4f35e3128fa492e45cfc5b0750524bc.tar.xz |
Merge branch 'develop' into markjh/config_cleanup
Conflicts: synapse/config/captcha.py
Diffstat (limited to 'synapse/storage/state.py')
-rw-r--r-- | synapse/storage/state.py | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/synapse/storage/state.py b/synapse/storage/state.py index 553ba9dd1f..95bc15c0dc 100644 --- a/synapse/storage/state.py +++ b/synapse/storage/state.py @@ -128,25 +128,18 @@ class StateStore(SQLBaseStore): @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 " - "LIMIT 1" - ) - sql = ( - "SELECT e.*, (%(redacted)s) AS redacted FROM events as e " - "INNER JOIN current_state_events as c ON e.event_id = c.event_id " - "INNER JOIN state_events as s ON e.event_id = s.event_id " - "WHERE c.room_id = ? " - ) % { - "redacted": del_sql, - } + "SELECT e.*, r.event_id FROM events as e" + " LEFT JOIN redactions as r ON r.redacts = e.event_id" + " INNER JOIN current_state_events as c ON e.event_id = c.event_id" + " WHERE c.room_id = ? " + ) if event_type and state_key is not None: - sql += " AND s.type = ? AND s.state_key = ? " + sql += " AND c.type = ? AND c.state_key = ? " args = (room_id, event_type, state_key) elif event_type: - sql += " AND s.type = ?" + sql += " AND c.type = ?" args = (room_id, event_type) else: args = (room_id, ) |