diff options
author | Yuki Nishijima <mail@yukinishijima.net> | 2015-04-13 20:08:35 -0700 |
---|---|---|
committer | Yuki Nishijima <mail@yukinishijima.net> | 2015-04-13 20:13:37 -0700 |
commit | 50cae600bd6f4a8d1b437368c82f65bc118f8417 (patch) | |
tree | e53d564c567a1caffc805621b254f92f3dd5446d /activerecord/test/cases | |
parent | 8ac458ad2e252ba041d9f4e42b94bd5997a622be (diff) | |
download | rails-50cae600bd6f4a8d1b437368c82f65bc118f8417.tar.gz rails-50cae600bd6f4a8d1b437368c82f65bc118f8417.tar.bz2 rails-50cae600bd6f4a8d1b437368c82f65bc118f8417.zip |
Add support for Set to Relation#where
Previously `#where` used to treat `Set`objects as nil, but now it treats
them as an array:
set = Set.new([1, 2])
Author.where(:id => set)
# => SELECT "authors".* FROM "authors" WHERE "authors"."id" IN (1, 2)
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/relations_test.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index 0cf44388fa..c3409a1ca8 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -848,6 +848,17 @@ class RelationTest < ActiveRecord::TestCase } end + def test_find_all_using_where_with_a_set + david = authors(:david) + mary = authors(:mary) + set = Set.new([david.id, mary.id]) + + assert_queries(1) { + relation = Author.where(:id => set) + assert_equal [david, mary], relation + } + end + def test_exists davids = Author.where(:name => 'David') assert davids.exists? |