From 24e297178776ca3e5d71cdf446e4394e7a1bcb5c Mon Sep 17 00:00:00 2001 From: Ellie Huxtable Date: Thu, 21 Apr 2022 09:19:54 +0100 Subject: [PATCH] Fix SQL cache query (#318) I just deployed the older version and it was falling back on the full count. Turns out this is because it won't upcast from INT4 to INT8 automatically, and it has to be manual At some point the underlying total should be changed to int8, but also I highly doubt anyone will have enough shell history to fill an int4 lol --- atuin-server/src/database.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/atuin-server/src/database.rs b/atuin-server/src/database.rs index e163d3a7..efde86a3 100644 --- a/atuin-server/src/database.rs +++ b/atuin-server/src/database.rs @@ -120,7 +120,7 @@ impl Database for Postgres { } async fn count_history_cached(&self, user: &User) -> Result { - let res: (i64,) = sqlx::query_as( + let res: (i32,) = sqlx::query_as( "select total from total_history_count_user where user_id = $1", ) @@ -128,7 +128,7 @@ impl Database for Postgres { .fetch_one(&self.pool) .await?; - Ok(res.0) + Ok(res.0 as i64) } async fn count_history_range(