1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Remove deprecated ActiveRecord::Result#to_hash method

This commit is contained in:
Rafael Mendonça França 2020-05-06 23:03:58 -04:00
parent 317465a4a8
commit b6d62491e4
No known key found for this signature in database
GPG key ID: FC23B6D0F1EEE948
4 changed files with 6 additions and 18 deletions

View file

@ -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*

View file

@ -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

View file

@ -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)

View file

@ -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