From 762638a6815d2cdfa0908cf20b24dc22e75440a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Gruszczy=C5=84ski?= Date: Tue, 28 Jul 2026 12:05:47 +0200 Subject: [PATCH] aggregate data fix --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/db/mod.rs | 8 +++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b33ed15..9658db7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2581,7 +2581,7 @@ dependencies = [ [[package]] name = "rustpad" -version = "0.1.15" +version = "0.1.16" dependencies = [ "argon2", "aws-config", diff --git a/Cargo.toml b/Cargo.toml index 57b463d..db53c2d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rustpad" -version = "0.1.15" +version = "0.1.16" edition = "2024" rust-version = "1.94" description = "Collaborative Markdown notepad built with Axum, WebSockets and SQLite, PostgreSQL and MySQL" diff --git a/src/db/mod.rs b/src/db/mod.rs index e47bf7c..c412b32 100644 --- a/src/db/mod.rs +++ b/src/db/mod.rs @@ -181,11 +181,13 @@ pub async fn list_note_stats( DatabaseKind::Postgres => "$1", DatabaseKind::Sqlite | DatabaseKind::MySql => "?", }; - // PostgreSQL promotes SUM(BIGINT) to NUMERIC. sqlx::Any cannot decode the - // database-specific NUMERIC type, so normalize the aggregate to BIGINT. + // PostgreSQL and MySQL promote SUM(BIGINT) to database-specific decimal + // types. sqlx::Any cannot decode those types, so normalize the aggregate + // to a signed 64-bit integer before reading it. let file_size_sum = match pool.kind() { DatabaseKind::Postgres => "COALESCE(SUM(f.size_bytes), 0)::BIGINT", - DatabaseKind::Sqlite | DatabaseKind::MySql => "COALESCE(SUM(f.size_bytes), 0)", + DatabaseKind::MySql => "CAST(COALESCE(SUM(f.size_bytes), 0) AS SIGNED)", + DatabaseKind::Sqlite => "COALESCE(SUM(f.size_bytes), 0)", }; let query = format!( "SELECT n.id AS note_id, \