From 00aa00c55caa2be5af392ea05492754344dc9349 Mon Sep 17 00:00:00 2001 From: asonix Date: Sun, 3 Sep 2023 21:58:31 -0500 Subject: [PATCH] postgres: Enable 'previous page' when less than full limit fit on previous page --- src/repo/postgres.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/repo/postgres.rs b/src/repo/postgres.rs index addba2b..cf36b9c 100644 --- a/src/repo/postgres.rs +++ b/src/repo/postgres.rs @@ -354,11 +354,11 @@ impl HashRepo for PostgresRepo { .or_filter(created_at.eq(timestamp).and(hash.gt(&bound_hash))) .order(created_at) .then_order_by(hash) - .offset(limit.saturating_sub(1) as i64) - .first::(&mut conn) + .limit(limit as i64) + .get_results::(&mut conn) .await - .optional() - .map_err(PostgresError::Diesel)?; + .map_err(PostgresError::Diesel)? + .pop(); (page, prev) } else {