diesel/expression/functions/aggregate_expressions/
prefix.rs1use super::AggregateExpression;
2use super::IsAggregateFunction;
3use super::NoFilter;
4use super::NoOrder;
5use super::NoWindow;
6use crate::query_builder::{AstPass, QueryFragment, QueryId};
7use crate::QueryResult;
8
9pub struct NoPrefix;
#[automatically_derived]
impl ::core::fmt::Debug for NoPrefix {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f, "NoPrefix")
}
}
#[automatically_derived]
impl ::core::clone::Clone for NoPrefix {
#[inline]
fn clone(&self) -> NoPrefix { *self }
}
#[automatically_derived]
impl ::core::marker::Copy for NoPrefix { }
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl diesel::query_builder::QueryId for NoPrefix {
type QueryId = NoPrefix<>;
const HAS_STATIC_QUERY_ID: bool = true;
const IS_WINDOW_FUNCTION: bool = false;
}
};
impl<DB> crate::query_builder::QueryFragment<DB> for NoPrefix where
DB: crate::backend::Backend + crate::backend::DieselReserveSpecialization
{
fn walk_ast<'b>(&'b self,
_pass: crate::query_builder::AstPass<'_, 'b, DB>)
-> crate::QueryResult<()> {
Ok(())
}
}empty_clause!(NoPrefix);
10
11#[derive(#[automatically_derived]
impl ::core::fmt::Debug for All {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f, "All")
}
}Debug, #[automatically_derived]
impl ::core::clone::Clone for All {
#[inline]
fn clone(&self) -> All { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for All { }Copy, const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl diesel::query_builder::QueryId for All {
type QueryId = All<>;
const HAS_STATIC_QUERY_ID: bool = true;
const IS_WINDOW_FUNCTION: bool = false;
}
};QueryId)]
12pub struct All;
13
14impl<DB> QueryFragment<DB> for All
15where
16 DB: crate::backend::Backend,
17{
18 fn walk_ast<'b>(&'b self, mut pass: AstPass<'_, 'b, DB>) -> QueryResult<()> {
19 pass.push_sql(" ALL ");
20 Ok(())
21 }
22}
23
24#[derive(#[automatically_derived]
impl ::core::fmt::Debug for Distinct {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f, "Distinct")
}
}Debug, #[automatically_derived]
impl ::core::clone::Clone for Distinct {
#[inline]
fn clone(&self) -> Distinct { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for Distinct { }Copy, const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl diesel::query_builder::QueryId for Distinct {
type QueryId = Distinct<>;
const HAS_STATIC_QUERY_ID: bool = true;
const IS_WINDOW_FUNCTION: bool = false;
}
};QueryId)]
25pub struct Distinct;
26
27impl<DB> QueryFragment<DB> for Distinct
28where
29 DB: crate::backend::Backend,
30{
31 fn walk_ast<'b>(&'b self, mut pass: AstPass<'_, 'b, DB>) -> QueryResult<()> {
32 pass.push_sql(" DISTINCT ");
33 Ok(())
34 }
35}
36
37pub trait DistinctDsl {
38 type Output;
39
40 fn distinct(self) -> Self::Output;
41}
42
43impl<T> DistinctDsl for T
44where
45 T: IsAggregateFunction,
46{
47 type Output = AggregateExpression<T, Distinct>;
48
49 fn distinct(self) -> Self::Output {
50 AggregateExpression {
51 prefix: Distinct,
52 function: self,
53 order: NoOrder,
54 filter: NoFilter,
55 window: NoWindow,
56 }
57 }
58}
59
60impl<T, Prefix, Order, Filter> DistinctDsl
61 for AggregateExpression<T, Prefix, Order, Filter, NoWindow>
62where
63 T: IsAggregateFunction,
64{
65 type Output = AggregateExpression<T, Distinct, Order, Filter, NoWindow>;
66
67 fn distinct(self) -> Self::Output {
68 AggregateExpression {
69 prefix: Distinct,
70 function: self.function,
71 order: self.order,
72 filter: self.filter,
73 window: self.window,
74 }
75 }
76}
77
78pub trait AllDsl {
79 type Output;
80
81 fn all(self) -> Self::Output;
82}
83
84impl<T> AllDsl for T
85where
86 T: IsAggregateFunction,
87{
88 type Output = AggregateExpression<T, All>;
89
90 fn all(self) -> Self::Output {
91 AggregateExpression {
92 prefix: All,
93 function: self,
94 order: NoOrder,
95 filter: NoFilter,
96 window: NoWindow,
97 }
98 }
99}
100
101impl<T, Prefix, Order, Filter> AllDsl for AggregateExpression<T, Prefix, Order, Filter, NoWindow>
102where
103 T: IsAggregateFunction,
104{
105 type Output = AggregateExpression<T, All, Order, Filter, NoWindow>;
106
107 fn all(self) -> Self::Output {
108 AggregateExpression {
109 prefix: All,
110 function: self.function,
111 order: self.order,
112 filter: self.filter,
113 window: self.window,
114 }
115 }
116}