From 9cf7e3494f5bd34f1382c1ff4ea3d811a4972ae2 Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Tue, 26 Sep 2017 13:22:12 -0600 Subject: Treat `Set` as an `Array` in `Relation#where` I do not want to set the expectation that any enumerable object should behave this way, but this case in particular comes up frequently enough that I'm caving on this one. Fixes #30684. --- activerecord/test/cases/relations_test.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'activerecord/test') diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index ae1dc35bff..6270533dc2 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -1912,6 +1912,19 @@ class RelationTest < ActiveRecord::TestCase end end + test "#where with set" do + david = authors(:david) + mary = authors(:mary) + + authors = Author.where(name: ["David", "Mary"].to_set) + assert_equal [david, mary], authors + end + + test "#where with empty set" do + authors = Author.where(name: Set.new) + assert_empty authors + end + private def custom_post_relation table_alias = Post.arel_table.alias("omg_posts") -- cgit v1.2.3