use super::AggregateExpression; use super::IsAggregateFunction; use super::NoFilter; use super::NoOrder; use super::NoWindow; use crate::query_builder::{AstPass, QueryFragment, QueryId}; use crate::QueryResult; empty_clause!(NoPrefix); #[derive(Debug, Clone, Copy, QueryId)] pub struct All; impl QueryFragment for All where DB: crate::backend::Backend, { fn walk_ast<'b>(&'b self, mut pass: AstPass<'_, 'b, DB>) -> QueryResult<()> { pass.push_sql(" ALL "); Ok(()) } } #[derive(Debug, Clone, Copy, QueryId)] pub struct Distinct; impl QueryFragment for Distinct where DB: crate::backend::Backend, { fn walk_ast<'b>(&'b self, mut pass: AstPass<'_, 'b, DB>) -> QueryResult<()> { pass.push_sql(" DISTINCT "); Ok(()) } } pub trait DistinctDsl { type Output; fn distinct(self) -> Self::Output; } impl DistinctDsl for T where T: IsAggregateFunction, { type Output = AggregateExpression; fn distinct(self) -> Self::Output { AggregateExpression { prefix: Distinct, function: self, order: NoOrder, filter: NoFilter, window: NoWindow, } } } impl DistinctDsl for AggregateExpression where T: IsAggregateFunction, { type Output = AggregateExpression; fn distinct(self) -> Self::Output { AggregateExpression { prefix: Distinct, function: self.function, order: self.order, filter: self.filter, window: self.window, } } } pub trait AllDsl { type Output; fn all(self) -> Self::Output; } impl AllDsl for T where T: IsAggregateFunction, { type Output = AggregateExpression; fn all(self) -> Self::Output { AggregateExpression { prefix: All, function: self, order: NoOrder, filter: NoFilter, window: NoWindow, } } } impl AllDsl for AggregateExpression where T: IsAggregateFunction, { type Output = AggregateExpression; fn all(self) -> Self::Output { AggregateExpression { prefix: All, function: self.function, order: self.order, filter: self.filter, window: self.window, } } }