Files
zulip/zerver/lib/message.py
Prakhar Pratyush 859cc29657 unread_data: Ensure deterministic ordering of unread message rows.
Earlier, in `get_raw_unread_data` the ordering was applied inside
the CTE.

Once we leave the CTE scope and do a join, SQL makes no promise
about preserving the row order unless we re-specify ORDER BY in
the outer query.

Since, there was no ORDER BY clause in the outer query it was
resulting in a random ordering of the entries. This bug was caught
by `test_unreads_case_insensitive_topics` failing in a flaky way.

This commit fixes the bug.

(cherry picked from commit ccc82976dc)
2025-05-07 15:38:22 -07:00

65 KiB