Skip to content

Commit

Permalink
Revert "Speed up integer casting from DB"
Browse files Browse the repository at this point in the history
This reverts commit 52fddcc.

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.
  • Loading branch information
kamipo committed Feb 21, 2019
1 parent 8e66548 commit 9c9c950
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 6 deletions.
5 changes: 0 additions & 5 deletions activemodel/lib/active_model/type/integer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ def type
:integer
end

def deserialize(value)
return if value.nil?
value.to_i
end

def serialize(value)
result = super
if result
Expand Down
2 changes: 1 addition & 1 deletion activemodel/test/cases/type/integer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class IntegerTest < ActiveModel::TestCase
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
Expand Down

0 comments on commit 9c9c950

Please sign in to comment.