New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate ActiveRecord::Result#to_hash in favor of #to_a #33912

Merged
merged 1 commit into from Sep 20, 2018

Conversation

Projects
None yet
6 participants
@gmcgibbon
Member

gmcgibbon commented Sep 18, 2018

Summary

Rebased version of #23404 with deprecation. Adds deprecation warning for ActiveRecord::Result#to_hash in favor of ActiveRecord::Result#to_a.

Closes #23404.

@rails-bot

This comment has been minimized.

Show comment
Hide comment
@rails-bot

rails-bot Sep 18, 2018

Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @schneems (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

This repository is being automatically checked for code quality issues using Code Climate. You can see results for this analysis in the PR status below. Newly introduced issues should be fixed before a Pull Request is considered ready to review.

Please see the contribution instructions for more information.

rails-bot commented Sep 18, 2018

Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @schneems (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

This repository is being automatically checked for code quality issues using Code Climate. You can see results for this analysis in the PR status below. Newly introduced issues should be fixed before a Pull Request is considered ready to review.

Please see the contribution instructions for more information.

@bogdanvlviv

We should add a changelog entry for that change.

Show outdated Hide outdated activerecord/lib/active_record/result.rb Outdated
Deprecate ActiveRecord::Result#to_hash in favor of #to_a
method returns an array of hashes, not a hash
e.g. Hash.try_convert(result) calls #to_hash and raises a TypeError

[Gannon McGibbon + Kevin Cheng]
@gmcgibbon

This comment has been minimized.

Show comment
Hide comment
@gmcgibbon

gmcgibbon Sep 18, 2018

Member

Changes made. Thanks for reviewing!

Member

gmcgibbon commented Sep 18, 2018

Changes made. Thanks for reviewing!

@rafaelfranca rafaelfranca merged commit 4586b30 into rails:master Sep 20, 2018

2 checks passed

codeclimate All good!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

bogdanvlviv added a commit to bogdanvlviv/rails that referenced this pull request Sep 20, 2018

Make `ActiveRecord::Result#to_a` as alias to `ActiveRecord::Result#to…
…_ary`

`ActiveRecord::Result#to_a` was introduced in rails#33912.

I would prefer to make `to_a` as alias to the `to_ary` because:
  - It would be clear for users from https://edgeapi.rubyonrails.org/classes/ActiveRecord/Result.html
    that `to_a` and `to_ary` are the same
  - For us it would take less efforts in case if we needed to change the docs
    or implementation, since the methods are the same

Follow up rails#33912

@gmcgibbon gmcgibbon deleted the gmcgibbon:ar_result_to_hash_deprecate branch Sep 21, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment