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 group_by_grouping_sets query method #161

Merged
merged 1 commit into from
Oct 9, 2024

Conversation

leboshi
Copy link
Contributor

@leboshi leboshi commented Sep 6, 2024

Implements GROUP BY GROUPING SETS. (Haven't done CUBE or ROLLUP yet.)

Example:

users = User.group_by_grouping_sets([], [:name], [:name, :age]).select(:name, :age, 'count(*)')

generates:

SELECT name, age, count(*) FROM users GROUP BY GROUPING SETS ( (), (name), (name, age) )

Accepts arrays of strings, symbols, and Arel nodes, as well as any arbitrary mix of them.

@PNixx PNixx merged commit f730c49 into PNixx:master Oct 9, 2024
16 checks passed
@leboshi leboshi deleted the feature/grouping-sets branch December 10, 2024 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants