Skip to content

Commit

Permalink
Fix between stringify enum values to return the expected result
Browse files Browse the repository at this point in the history
  • Loading branch information
kamipo committed Mar 10, 2021
1 parent 55d913d commit 3b6461b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/enum.rb
Expand Up @@ -129,7 +129,7 @@ def cast(value)
elsif mapping.has_value?(value)
mapping.key(value)
else
value.presence
subtype.cast(value.presence)
end
end

Expand Down
3 changes: 3 additions & 0 deletions activerecord/test/cases/enum_test.rb
Expand Up @@ -96,6 +96,9 @@ class EnumTest < ActiveRecord::TestCase

test "find via where with large number" do
assert_equal @book, Book.where(status: [2, 9223372036854775808]).first
assert_equal @book, Book.where(status: ["2", "9223372036854775808"]).first
assert_equal @book, Book.where(status: 2..9223372036854775808).first
assert_equal @book, Book.where(status: "2".."9223372036854775808").first
end

test "find via where should be type casted" do
Expand Down

0 comments on commit 3b6461b

Please sign in to comment.