From a741208f80dd33420a56486bd9ed2b0b9862234a Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Mon, 12 Nov 2018 03:39:28 +0900 Subject: Ensure casting by decimal attribute when querying Related 34cc301f03aea2e579d6687a9ea9782afc1089a0. `QueryAttribute#value_for_database` calls only `type.serialize`, and `Decimal#serialize` is a no-op unlike other attribute types. Whether or not `serialize` will invoke `cast` is undefined in our test cases, but it actually does not work properly unless it does so for now. --- activemodel/lib/active_model/type/decimal.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'activemodel/lib/active_model/type') diff --git a/activemodel/lib/active_model/type/decimal.rb b/activemodel/lib/active_model/type/decimal.rb index e8ee18c00e..b37dad1c41 100644 --- a/activemodel/lib/active_model/type/decimal.rb +++ b/activemodel/lib/active_model/type/decimal.rb @@ -12,6 +12,10 @@ module ActiveModel :decimal end + def serialize(value) + cast(value) + end + def type_cast_for_schema(value) value.to_s.inspect end -- cgit v1.2.3