1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Revert "Speed up integer casting from DB"

This reverts commit 52fddcc653.

52fddcc was to short-circuit `ensure_in_range` in `cast_value`. But that
caused a regression for empty string deserialization.

Since 7c6f393, `ensure_in_range` is moved into `serialize`. As 52fddcc
said, the absolute gain is quite small. So I've reverted that commit to
fix the regression.
This commit is contained in:
Ryuta Kamizono 2019-02-21 13:10:14 +09:00
parent 8e66548b08
commit 9c9c950d02
2 changed files with 1 additions and 6 deletions

View file

@ -18,11 +18,6 @@ module ActiveModel
:integer
end
def deserialize(value)
return if value.nil?
value.to_i
end
def serialize(value)
result = super
if result

View file

@ -54,7 +54,7 @@ module ActiveModel
type = Type::Integer.new
assert_nil type.cast("")
assert_nil type.serialize("")
assert_equal 0, type.deserialize("")
assert_nil type.deserialize("")
end
test "changed?" do