qraft_core/select/
group.rs1use crate::{
4 count_idents,
5 expression::Expression,
6 impl_for_all_tuples,
7 lower::{Instructions, LowerCtx},
8};
9
10pub trait LowerGroupBy {
12 fn lower_group_by(self, ctx: &mut LowerCtx);
14}
15
16impl<E> LowerGroupBy for E
17where
18 E: Expression,
19{
20 fn lower_group_by(self, ctx: &mut LowerCtx) {
21 self.lower(ctx);
22 }
23}
24
25macro_rules! impl_groupby_macro {
26 ($($T:ident),+) => {
27 impl<$($T,)+> LowerGroupBy for ($($T,)+)
28 where
29 $($T: LowerGroupBy,)+
30 {
31 fn lower_group_by(self, ctx: &mut LowerCtx) {
32 #[allow(non_snake_case)]
33 let ($($T,)+) = self;
34 $(
35 $T.lower_group_by(ctx);
36 )+
37 let count = count_idents!($($T,)+);
38 ctx.instrs.push_seperated(count);
39 }
40 }
41 };
42}
43
44impl_for_all_tuples!(impl_groupby_macro);