From b6d62491e4067dbbde05a54b6a32267021305fac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Wed, 6 May 2020 23:03:58 -0400 Subject: [PATCH] Remove deprecated `ActiveRecord::Result#to_hash` method --- activerecord/CHANGELOG.md | 4 ++++ activerecord/lib/active_record/result.rb | 8 -------- activerecord/test/cases/result_test.rb | 10 ---------- guides/source/6_1_release_notes.md | 2 ++ 4 files changed, 6 insertions(+), 18 deletions(-) diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index 3b111d1538..059dc53128 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,3 +1,7 @@ +* Remove deprecated `ActiveRecord::Result#to_hash` method. + + *Rafael Mendonça França* + * Deprecate `ActiveRecord::Base.allow_unsafe_raw_sql`. *Rafael Mendonça França* diff --git a/activerecord/lib/active_record/result.rb b/activerecord/lib/active_record/result.rb index e0710266b4..168d95cbf4 100644 --- a/activerecord/lib/active_record/result.rb +++ b/activerecord/lib/active_record/result.rb @@ -65,14 +65,6 @@ module ActiveRecord end end - def to_hash - ActiveSupport::Deprecation.warn(<<-MSG.squish) - `ActiveRecord::Result#to_hash` has been renamed to `to_a`. - `to_hash` is deprecated and will be removed in Rails 6.1. - MSG - to_a - end - alias :map! :map alias :collect! :map deprecate "map!": :map diff --git a/activerecord/test/cases/result_test.rb b/activerecord/test/cases/result_test.rb index cf3da5b62e..814a551978 100644 --- a/activerecord/test/cases/result_test.rb +++ b/activerecord/test/cases/result_test.rb @@ -51,16 +51,6 @@ module ActiveRecord ], result.to_a end - test "to_hash (deprecated) returns row_hashes" do - assert_deprecated do - assert_equal [ - { "col_1" => "row 1 col 1", "col_2" => "row 1 col 2" }, - { "col_1" => "row 2 col 1", "col_2" => "row 2 col 2" }, - { "col_1" => "row 3 col 1", "col_2" => "row 3 col 2" }, - ], result.to_hash - end - end - test "first returns first row as a hash" do assert_equal( { "col_1" => "row 1 col 1", "col_2" => "row 1 col 2" }, result.first) diff --git a/guides/source/6_1_release_notes.md b/guides/source/6_1_release_notes.md index bd1629c4c1..c697c15c19 100644 --- a/guides/source/6_1_release_notes.md +++ b/guides/source/6_1_release_notes.md @@ -149,6 +149,8 @@ Please refer to the [Changelog][active-record] for detailed changes. ### Removals +* Remove deprecated `ActiveRecord::Result#to_hash` method. + * Remove deprecated support for using unsafe raw SQL in `ActiveRecord::Relation` methods. ### Deprecations