Skip to content
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

Add regroup method to ActiveRecord #47010

Merged
merged 1 commit into from
Jan 16, 2023
Merged

Add regroup method to ActiveRecord #47010

merged 1 commit into from
Jan 16, 2023

Conversation

dvisockas
Copy link
Contributor

@dvisockas dvisockas commented Jan 14, 2023

Motivation / Background

Currently there is no one-method way to override previously set group statement (as is the case for select, where and reorder).

Detail

Adds regroup and regroup! methods that override group_values instead of appending to the array (as is the case for #group).

Additional information

Alternative solutions for Post.group(:title).regroup(:author) is:

Post.group(:title).unscope(:group).group(:author)

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Changes that are unrelated should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug or add a feature.
  • CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.

@dvisockas
Copy link
Contributor Author

cc @casperisfine

@byroot byroot merged commit f519d71 into rails:main Jan 16, 2023
paracycle added a commit to Shopify/tapioca that referenced this pull request Jul 19, 2023
kamipo added a commit that referenced this pull request Sep 26, 2023
This was accidentally changed at #47010.
koic added a commit to koic/rubocop-rails that referenced this pull request Oct 14, 2023
…iveRecordAllMethod`

Follow up rails/rails#44446, rails/rails#37944,
rails/rails#46503, and rails/rails#47010.

This PR supports some Rails 7.1's new querying methods for `Rails/RedundantActiveRecordAllMethod`.
koic added a commit to koic/rubocop-rails that referenced this pull request Oct 14, 2023
…iveRecordAllMethod`

Follow up rails/rails#44446, rails/rails#37944,
rails/rails#46503, and rails/rails#47010.

This PR supports some Rails 7.1's new querying methods for `Rails/RedundantActiveRecordAllMethod`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants