Skip to content

Add regroup method to ActiveRecord - #47010

Merged
byroot merged 1 commit into
rails:mainfrom
dvisockas:main
Jan 16, 2023
Merged

byroot merged 1 commit into
rails:mainfrom
dvisockas:main

Conversation

@dvisockas

@dvisockas dvisockas commented Jan 14, 2023 •

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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.

2 participants