Skip to content
Clone

fix(admin): cast attachment byte totals to bigint

SUM(size) on an integer column comes back as numeric, which SeaQuery cannot

decode into Option<i64>; the storage-usage and room-statistics panels 500
without the explicit cast.
ZhenYi committed
parent 79bd077 commit 001c5fe Browse files

1 file changed

+2 −2

Modified lib/admin/src/services/chat.rs View lib/admin/src/services/chat.rs
@@ -445,7 +445,7 @@
445445 .await? as i64;
446446 let attachment_bytes = attachments::Entity::find()
447447 .select_only()
448 .column_as(Expr::col(attachments::Column::Size).sum(), "total")
448 .column_as(Expr::col(attachments::Column::Size).sum().cast_as("bigint"), "total")
449449 .into_tuple::<Option<i64>>()
450450 .one(self.db().read())
451451 .await?
@@ -693,7 +693,7 @@
693693 let attachment_bytes = attachments::Entity::find()
694694 .filter(attachments::Column::RoomId.eq(room_id))
695695 .select_only()
696 .column_as(Expr::col(attachments::Column::Size).sum(), "total")
696 .column_as(Expr::col(attachments::Column::Size).sum().cast_as("bigint"), "total")
697697 .into_tuple::<Option<i64>>()
698698 .one(self.db().read())
699699 .await?