aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorSean Griffin <sean@seantheprogrammer.com>2014-12-04 15:54:45 -0700
committerSean Griffin <sean@seantheprogrammer.com>2014-12-04 15:54:45 -0700
commitbbbe9cfc61bf0ab8f6b672d394fa00bdb9941fc3 (patch)
tree1a0bab24f153a5870b05eee9bc82f409a6b31680 /activerecord
parentd1f003e67b6438a0c5367962fa1a35cd22e7cc8c (diff)
parentbe6897e34d8a53d07eb62637ef3d0a1be660d432 (diff)
downloadrails-bbbe9cfc61bf0ab8f6b672d394fa00bdb9941fc3.tar.gz
rails-bbbe9cfc61bf0ab8f6b672d394fa00bdb9941fc3.tar.bz2
rails-bbbe9cfc61bf0ab8f6b672d394fa00bdb9941fc3.zip
Merge pull request #17919 from mrgilman/stop-supporting-nested-arrays
Remove deprecated behavior allowing nested arrays as query values
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/CHANGELOG.md5
-rw-r--r--activerecord/lib/active_record/relation/predicate_builder/array_handler.rb10
-rw-r--r--activerecord/test/cases/finder_test.rb24
-rw-r--r--activerecord/test/cases/relation/where_test.rb6
4 files changed, 5 insertions, 40 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md
index f0d9f1e538..152cbc751c 100644
--- a/activerecord/CHANGELOG.md
+++ b/activerecord/CHANGELOG.md
@@ -1,3 +1,8 @@
+* Remove deprecated behavior allowing nested arrays to be passed as query
+ values.
+
+ *Melanie Gilman*
+
* Deprecate passing a class as a value in a query. Users should pass strings
instead.
diff --git a/activerecord/lib/active_record/relation/predicate_builder/array_handler.rb b/activerecord/lib/active_record/relation/predicate_builder/array_handler.rb
index b8f3285c3e..4cba297be5 100644
--- a/activerecord/lib/active_record/relation/predicate_builder/array_handler.rb
+++ b/activerecord/lib/active_record/relation/predicate_builder/array_handler.rb
@@ -7,16 +7,6 @@ module ActiveRecord
values = value.map { |x| x.is_a?(Base) ? x.id : x }
nils, values = values.partition(&:nil?)
- if values.any? { |val| val.is_a?(Array) }
- ActiveSupport::Deprecation.warn(<<-MSG.squish)
- Passing a nested array to Active Record finder methods is
- deprecated and will be removed. Flatten your array before using
- it for 'IN' conditions.
- MSG
-
- values = values.flatten
- end
-
return attribute.in([]) if values.empty? && nils.empty?
ranges, values = values.partition { |v| v.is_a?(Range) }
diff --git a/activerecord/test/cases/finder_test.rb b/activerecord/test/cases/finder_test.rb
index d4272bb9d1..5c98be342f 100644
--- a/activerecord/test/cases/finder_test.rb
+++ b/activerecord/test/cases/finder_test.rb
@@ -546,30 +546,6 @@ class FinderTest < ActiveRecord::TestCase
assert_equal [1,2,6,7,8], Comment.where(id: [1..2, 6..8]).to_a.map(&:id).sort
end
- def test_find_on_hash_conditions_with_nested_array_of_integers_and_ranges
- assert_deprecated do
- assert_equal [1,2,3,5,6,7,8,9], Comment.where(id: [[1..2], 3, [5], 6..8, 9]).to_a.map(&:id).sort
- end
- end
-
- def test_find_on_hash_conditions_with_array_of_integers_and_arrays
- assert_deprecated do
- assert_equal [1,2,3,5,6,7,8,9], Comment.where(id: [[1, 2], 3, 5, [6, [7], 8], 9]).to_a.map(&:id).sort
- end
- end
-
- def test_find_on_hash_conditions_with_nested_array_of_integers_and_ranges_and_nils
- assert_deprecated do
- assert_equal [1,3,4,5], Topic.where(parent_id: [[2..6], nil]).to_a.map(&:id).sort
- end
- end
-
- def test_find_on_hash_conditions_with_nested_array_of_integers_and_ranges_and_more_nils
- assert_deprecated do
- assert_equal [], Topic.where(parent_id: [[7..10, nil, [nil]], [nil]]).to_a.map(&:id).sort
- end
- end
-
def test_find_on_multiple_hash_conditions
assert Topic.where(author_name: "David", title: "The First Topic", replies_count: 1, approved: false).find(1)
assert_raise(ActiveRecord::RecordNotFound) { Topic.where(author_name: "David", title: "The First Topic", replies_count: 1, approved: true).find(1) }
diff --git a/activerecord/test/cases/relation/where_test.rb b/activerecord/test/cases/relation/where_test.rb
index a453203e15..d675953da6 100644
--- a/activerecord/test/cases/relation/where_test.rb
+++ b/activerecord/test/cases/relation/where_test.rb
@@ -181,12 +181,6 @@ module ActiveRecord
assert_equal 0, Post.where(:id => []).count
end
- def test_where_with_table_name_and_nested_empty_array
- assert_deprecated do
- assert_equal [], Post.where(:id => [[]]).to_a
- end
- end
-
def test_where_with_empty_hash_and_no_foreign_key
assert_equal 0, Edge.where(:sink => {}).count
end