diesel

Macro allow_columns_to_appear_in_same_group_by_clause

Source
macro_rules! allow_columns_to_appear_in_same_group_by_clause {
    ($($left_path:tt)::+, $($right_path:tt)::+ $(,)?) => { ... };
    ($($left_path:tt)::+, $($right_path:tt)::+, $($other: tt)*) => { ... };
    ($last_col:ty,) => { ... };
    () => { ... };
}
Expand description

Allow two or more columns which are otherwise unrelated to be used together in a group by clause.

This macro must be invoked any time two columns need to appear in the same group by clause. When this macro is invoked with more than 2 columns, every combination of those columns will be allowed to appear together.

ยงExample

// This would be required

allow_columns_to_appear_in_same_group_by_clause!(users::name, posts::id, posts::title);
// to do implement the following join
users::table.inner_join(posts::table).group_by((users::name, posts::id, posts::title))

When more than two columns are passed, the relevant code is generated for every combination of those columns. This code would be equivalent to the previous example.

allow_columns_to_appear_in_same_group_by_clause!(users::name, posts::title);
allow_columns_to_appear_in_same_group_by_clause!(users::name, posts::id);
allow_columns_to_appear_in_same_group_by_clause!(posts::title, posts::id);