Correctly order when selecting before stream ordering

pull/6714/head
Brendan Abolivier 2020-01-15 19:32:47 +00:00
parent 8363588237
commit 066b9f52b8
No known key found for this signature in database
GPG Key ID: 1E015C145F1916CD
1 changed files with 5 additions and 2 deletions

View File

@ -580,9 +580,12 @@ class StreamWorkerStore(EventsWorkerStore, SQLBaseStore):
" FROM events" " FROM events"
" WHERE room_id = ? AND stream_ordering %s ?" " WHERE room_id = ? AND stream_ordering %s ?"
" AND NOT outlier" " AND NOT outlier"
" ORDER BY stream_ordering" " ORDER BY stream_ordering %s"
" LIMIT 1" " LIMIT 1"
) % ("<=" if dir == "b" else ">=",) ) % (
"<=" if dir == "b" else ">=",
"DESC" if dir == "b" else "ASC",
)
txn.execute(sql, (room_id, stream_ordering)) txn.execute(sql, (room_id, stream_ordering))
return txn.fetchone() return txn.fetchone()