forked from diesel-rs/diesel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement
ValidGrouping<GB>
for more cases
This commit adds support for more kinds of `GROUP BY` clauses. * We implement now `ValidGrouping<table::primary_key, IsAggregate = Yes>` for each column of that table, as according to the postgres documentation it is sufficient to have only the primary key in the group by clause * We provide a basic infrastructure to handle `GROUP BY` clauses consisting of more than one column by introducing a `IsContainedInGroupBy` helper trait. It is currently used to check if a column is part of a composite `GROUP BY` clause by checking if the corresponding tuple contains this column. As basic requirement an `impl IsContainedInGroupBy<column_a> for column_b { type Output = No; }` is required for each pair `column_a` and `column_b` that should be allowed to appear together in a `GROUP BY` clause. This is automatically implemented for all columns belonging to one table. For cross table cases the `allow_columns_to_appear_in_same_group_by_clause!` macro is provided. (This macros just skips the default per table generated impls). As future extension we may want to generate a call to that macro for all columns in a generated schema, after checking the impact on compile times of having that much impls. * Additionally this commit adds a bunch of test cases that cover the old and new allowed usecases of `GROUP BY` clauses Fixes diesel-rs#2370, CC diesel-rs#210
- Loading branch information
Showing
8 changed files
with
612 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.