Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
message_fetch: Skip intermediate mutation in limit_query_to_range.
Anders Kaseorg8e0240300a2a
diff --git a/zerver/views/message_fetch.py b/zerver/views/message_fetch.pyindex 31d198cffc5..594135a91f4 100644--- a/zerver/views/message_fetch.py+++ b/zerver/views/message_fetch.py@@ -1121,11 +1121,11 @@ def limit_query_to_range(query: Query,after_query = after_query.limit(after_limit)if need_both_sides:- query = union_all(before_query.self_group(), after_query.self_group())+ return union_all(before_query.self_group(), after_query.self_group())elif need_before_query:- query = before_query+ return before_queryelif need_after_query:- query = after_query+ return after_queryelse:# If we don't have either a before_query or after_query, it's because# some combination of num_before/num_after/anchor are zero or@@ -1135,9 +1135,7 @@ def limit_query_to_range(query: Query,# for something like `message_id = 42` is exactly what we want. In other# cases, which could possibly be buggy API clients, at least we will# return at most one row here.- query = query.where(id_col == anchor)-- return query+ return query.where(id_col == anchor)def post_process_limited_query(rows: List[Any],num_before: int,