diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/oid/float.rb b/activerecord/lib/active_record/connection_adapters/postgresql/oid/float.rb index 9753d71461f87f41a4953f0d1e2cb5283e3c2ae2..77dd97e14025eb0a8308583c322b010da359152c 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/oid/float.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/oid/float.rb @@ -5,9 +5,8 @@ module OID # :nodoc: class Float < Type::Float include Infinity - def type_cast(value) + def cast_value(value) case value - when nil then nil when 'Infinity' then ::Float::INFINITY when '-Infinity' then -::Float::INFINITY when 'NaN' then ::Float::NAN diff --git a/activerecord/lib/active_record/type/numeric.rb b/activerecord/lib/active_record/type/numeric.rb index 9cc6411e7722b71fa11a830f5007f5717fb88a50..d5cb13233c8d85f8fe79633874346b1791009be3 100644 --- a/activerecord/lib/active_record/type/numeric.rb +++ b/activerecord/lib/active_record/type/numeric.rb @@ -5,13 +5,14 @@ def number? true end - def type_cast_for_write(value) - case value - when true then 1 - when false then 0 - when ::String then value.presence - else super - end + def type_cast(value) + value = case value + when true then 1 + when false then 0 + when ::String then value.presence + else value + end + super(value) end def changed?(old_value, new_value) # :nodoc: