Correct SQL statement for postgres
In standard sql, join binds tighter than comma, so we were joining on the wrong table. Postgres follows the standard (apparently).pull/759/head
parent
8cc82aad87
commit
80be396464
|
@ -120,14 +120,15 @@ class EventPushActionsStore(SQLBaseStore):
|
||||||
sql = (
|
sql = (
|
||||||
"SELECT ep.event_id, ep.room_id, ep.stream_ordering, ep.actions, "
|
"SELECT ep.event_id, ep.room_id, ep.stream_ordering, ep.actions, "
|
||||||
"e.received_ts "
|
"e.received_ts "
|
||||||
"FROM event_push_actions AS ep, ("
|
"FROM ("
|
||||||
" SELECT room_id, user_id, "
|
" SELECT room_id, user_id, "
|
||||||
" max(topological_ordering) as topological_ordering, "
|
" max(topological_ordering) as topological_ordering, "
|
||||||
" max(stream_ordering) as stream_ordering "
|
" max(stream_ordering) as stream_ordering "
|
||||||
" FROM events"
|
" FROM events"
|
||||||
" NATURAL JOIN receipts_linearized WHERE receipt_type = 'm.read'"
|
" NATURAL JOIN receipts_linearized WHERE receipt_type = 'm.read'"
|
||||||
" GROUP BY room_id, user_id"
|
" GROUP BY room_id, user_id"
|
||||||
") AS rl"
|
") AS rl,"
|
||||||
|
" event_push_actions AS ep"
|
||||||
" INNER JOIN events AS e USING (room_id, event_id)"
|
" INNER JOIN events AS e USING (room_id, event_id)"
|
||||||
" WHERE"
|
" WHERE"
|
||||||
" ep.room_id = rl.room_id"
|
" ep.room_id = rl.room_id"
|
||||||
|
|
Loading…
Reference in New Issue