From 5f3bd55726703e08ba595555e1cf428c57832603 Mon Sep 17 00:00:00 2001
From: Santiago Pastorino <santiago@wyeworks.com>
Date: Wed, 12 May 2010 01:47:58 -0300
Subject: type_cast_calculated_value refactor: value is never a Fixnum here.
 Fix test since SQLite returns Float.

[#4514 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
---
 activerecord/lib/active_record/relation/calculations.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'activerecord/lib')

diff --git a/activerecord/lib/active_record/relation/calculations.rb b/activerecord/lib/active_record/relation/calculations.rb
index 858d298470..0e11f89c8b 100644
--- a/activerecord/lib/active_record/relation/calculations.rb
+++ b/activerecord/lib/active_record/relation/calculations.rb
@@ -243,7 +243,7 @@ module ActiveRecord
         case operation
           when 'count' then value.to_i
           when 'sum'   then type_cast_using_column(value || '0', column)
-          when 'average' then value && (value.is_a?(Fixnum) ? value.to_f : value).to_d
+          when 'average' then value.try(:to_d)
           else type_cast_using_column(value, column)
         end
       else
-- 
cgit v1.2.3