From 6f40a9f3715fa02d12a78eacc34f7b1d86fd1cb3 Mon Sep 17 00:00:00 2001 From: Guillaume Dott Date: Wed, 25 Jan 2023 15:53:00 +0100 Subject: [PATCH] fix: correct precision and scale in select query --- lib/rating/models/rating/rating.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rating/models/rating/rating.rb b/lib/rating/models/rating/rating.rb index fccf85c..308503b 100644 --- a/lib/rating/models/rating/rating.rb +++ b/lib/rating/models/rating/rating.rb @@ -26,7 +26,7 @@ module Rating sql = %( SELECT - (CAST(#{total_count} AS DECIMAL(17, 14)) / #{distinct_count}) count_avg, + (CAST(#{total_count} AS DECIMAL(25, 16)) / #{distinct_count}) count_avg, COALESCE(AVG(value), 0) rating_avg FROM #{rate_table_name} WHERE