diesel/expression/
grouped.rs
1use crate::backend::{Backend, DieselReserveSpecialization};
2use crate::expression::{Expression, ValidGrouping};
3use crate::query_builder::*;
4use crate::result::QueryResult;
5use crate::sql_types::DieselNumericOps;
6
7#[derive(Debug, Copy, Clone, QueryId, Default, DieselNumericOps, ValidGrouping)]
8pub struct Grouped<T>(pub T);
9
10impl<T: Expression> Expression for Grouped<T> {
11 type SqlType = T::SqlType;
12}
13
14impl<T, DB> QueryFragment<DB> for Grouped<T>
15where
16 T: QueryFragment<DB>,
17 DB: Backend + DieselReserveSpecialization,
18{
19 fn walk_ast<'b>(&'b self, mut out: AstPass<'_, 'b, DB>) -> QueryResult<()> {
20 out.push_sql("(");
21 self.0.walk_ast(out.reborrow())?;
22 out.push_sql(")");
23 Ok(())
24 }
25}
26
27impl_selectable_expression!(Grouped<T>);