[][src]Derive Macro diesel::expression::ValidGrouping

#[derive(ValidGrouping)]
{
    // Attributes available to this derive:
    #[diesel]
}

Implements ValidGrouping

This trait can be automatically derived for structs with no type parameters which are never aggregate, as well as for structs which are NonAggregate when all type parameters are NonAggregate. For example:

This example is not tested
#[derive(ValidGrouping)]
struct LiteralOne;

#[derive(ValidGrouping)]
struct Plus<Lhs, Rhs>(Lhs, Rhs);

// The following impl will be generated:

impl<GroupByClause> ValidGrouping<GroupByClause> for LiteralOne {
    type IsAggregate = is_aggregate::Never;
}

impl<Lhs, Rhs, GroupByClause> ValidGrouping<GroupByClause> for Plus<Lhs, Rhs>
where
    Lhs: ValidGrouping<GroupByClause>,
    Rhs: ValidGrouping<GroupByClause>,
    Lhs::IsAggregate: MixedAggregates<Rhs::IsAggregate>,
{
    type IsAggregate = <Lhs::IsAggregate as MixedAggregates<Rhs::IsAggregate>>::Output;
}

For types which are always considered aggregate (such as an aggregate function), annotate your struct with #[diesel(aggregate)] to set IsAggregate explicitly to is_aggregate::Yes.

Attributes

Optional type attributes