From afe9d5b4094c9782aadd487d33a208b57320fbec Mon Sep 17 00:00:00 2001 From: Meng Zhang Date: Sun, 28 Apr 2024 01:55:49 -0700 Subject: [PATCH] fix(webserver): conditional query should be applied in source, before limit count --- ee/tabby-db/src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ee/tabby-db/src/lib.rs b/ee/tabby-db/src/lib.rs index f855953582a0..20efaa6b171e 100644 --- a/ee/tabby-db/src/lib.rs +++ b/ee/tabby-db/src/lib.rs @@ -71,6 +71,10 @@ fn make_pagination_query_with_condition( .select(&field_names.join(", ")) .order_by("id ASC"); + if let Some(condition) = condition { + source = source.where_and(&condition) + } + if backwards { source = source.order_by("id DESC"); if let Some(skip_id) = skip_id { @@ -89,10 +93,6 @@ fn make_pagination_query_with_condition( } select = select.from(&format!("({source})")); - if let Some(condition) = condition { - select = select.where_and(&condition) - } - select.as_string() }