1use crate::backend::sql_dialect;
2use crate::query_builder::{QueryFragment, QueryId};
3
4use super::aggregate_filter::NoFilter;
5use super::aggregate_order::{NoOrder, Order};
6use super::over_clause::{NoWindow, OverClause, ValidAggregateFilterForWindow};
7use super::partition_by::NoPartition;
8use super::prefix::NoPrefix;
9use super::{AggregateExpression, IsWindowFunction};
10
11pub struct NoFrame;
#[automatically_derived]
impl ::core::fmt::Debug for NoFrame {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f, "NoFrame")
}
}
#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for NoFrame { }
#[automatically_derived]
impl ::core::clone::Clone for NoFrame {
#[inline]
fn clone(&self) -> NoFrame { *self }
}
#[automatically_derived]
impl ::core::marker::Copy for NoFrame { }
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl diesel::query_builder::QueryId for NoFrame {
type QueryId = NoFrame<>;
const HAS_STATIC_QUERY_ID: bool = true;
const IS_WINDOW_FUNCTION: bool = false;
}
};
impl<DB> crate::query_builder::QueryFragment<DB> for NoFrame 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!(NoFrame);
12
13#[derive(const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl<F: diesel::query_builder::QueryId> diesel::query_builder::QueryId
for FrameClause<F> {
type QueryId =
FrameClause<<F as diesel::query_builder::QueryId>::QueryId>;
const HAS_STATIC_QUERY_ID: bool =
<F as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
true;
const IS_WINDOW_FUNCTION: bool =
<F as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
false;
}
};QueryId, #[automatically_derived]
impl<F: ::core::marker::Copy> ::core::marker::Copy for FrameClause<F> { }Copy, #[automatically_derived]
impl<F: ::core::clone::Clone> ::core::clone::Clone for FrameClause<F> {
#[inline]
fn clone(&self) -> FrameClause<F> {
FrameClause(::core::clone::Clone::clone(&self.0))
}
}Clone, #[automatically_derived]
impl<F: ::core::fmt::Debug> ::core::fmt::Debug for FrameClause<F> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_tuple_field1_finish(f, "FrameClause",
&&self.0)
}
}Debug)]
14pub struct FrameClause<F>(F);
15
16impl<F, DB> QueryFragment<DB> for FrameClause<F>
17where
18 F: QueryFragment<DB>,
19 DB: crate::backend::Backend,
20{
21 fn walk_ast<'b>(
22 &'b self,
23 pass: crate::query_builder::AstPass<'_, 'b, DB>,
24 ) -> crate::QueryResult<()> {
25 self.0.walk_ast(pass)?;
26 Ok(())
27 }
28}
29
30macro_rules! simple_frame_expr {
31 ($(#[doc = $doc: literal])* $name: ident, $kind: expr) => {
32 #[derive(QueryId, Clone, Copy, Debug)]
33 $(#[doc = $doc])*
34 pub struct $name;
35
36 impl<DB> QueryFragment<DB> for $name
37 where
38 DB: crate::backend::Backend,
39 {
40 fn walk_ast<'b>(
41 &'b self,
42 mut pass: crate::query_builder::AstPass<'_, 'b, DB>,
43 ) -> crate::QueryResult<()> {
44 pass.push_sql($kind);
45 Ok(())
46 }
47 }
48 };
49}
50
51macro_rules! simple_frame_expr_with_bound {
52 ($(#[doc = $doc:literal])* $name: ident, $option: ident, $bound: ty, $kind: expr) => {
53 #[derive(QueryId, Clone, Copy, Debug)]
54 $(#[doc = $doc])*
55 pub struct $name;
56
57 impl<DB> QueryFragment<DB> for $name
58 where
59 DB: crate::backend::Backend,
60 Self: QueryFragment<DB, DB::$option>,
61 {
62 fn walk_ast<'b>(
63 &'b self,
64 pass: crate::query_builder::AstPass<'_, 'b, DB>,
65 ) -> crate::QueryResult<()> {
66 <Self as QueryFragment<DB, DB::$option>>::walk_ast(self, pass)
67 }
68 }
69 impl<DB> QueryFragment<DB, $bound> for $name
70 where
71 DB: crate::backend::Backend<$option = $bound>,
72 {
73 fn walk_ast<'b>(
74 &'b self,
75 mut pass: crate::query_builder::AstPass<'_, 'b, DB>,
76 ) -> crate::QueryResult<()> {
77 pass.push_sql($kind);
78 Ok(())
79 }
80 }
81 };
82}
83
84#[doc = r" Range frame mode"]
#[doc = r""]
#[doc = r" Requires to set a `ORDER BY` clause set via `window_order`"]
#[doc = r" for the current window function call"]
pub struct Range;
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl diesel::query_builder::QueryId for Range {
type QueryId = Range<>;
const HAS_STATIC_QUERY_ID: bool = true;
const IS_WINDOW_FUNCTION: bool = false;
}
};
#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for Range { }
#[automatically_derived]
impl ::core::clone::Clone for Range {
#[inline]
fn clone(&self) -> Range { *self }
}
#[automatically_derived]
impl ::core::marker::Copy for Range { }
#[automatically_derived]
impl ::core::fmt::Debug for Range {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f, "Range")
}
}
impl<DB> QueryFragment<DB> for Range where DB: crate::backend::Backend {
fn walk_ast<'b>(&'b self,
mut pass: crate::query_builder::AstPass<'_, 'b, DB>)
-> crate::QueryResult<()> {
pass.push_sql(" RANGE ");
Ok(())
}
}simple_frame_expr!(
86 Range, " RANGE ");
91#[doc = r" Rows frame mode"]
#[doc = r""]
#[doc = r" This options specifies that the offset starts/ends"]
#[doc = r" a certain number of rows before/after the current row"]
pub struct Rows;
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl diesel::query_builder::QueryId for Rows {
type QueryId = Rows<>;
const HAS_STATIC_QUERY_ID: bool = true;
const IS_WINDOW_FUNCTION: bool = false;
}
};
#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for Rows { }
#[automatically_derived]
impl ::core::clone::Clone for Rows {
#[inline]
fn clone(&self) -> Rows { *self }
}
#[automatically_derived]
impl ::core::marker::Copy for Rows { }
#[automatically_derived]
impl ::core::fmt::Debug for Rows {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f, "Rows")
}
}
impl<DB> QueryFragment<DB> for Rows where DB: crate::backend::Backend {
fn walk_ast<'b>(&'b self,
mut pass: crate::query_builder::AstPass<'_, 'b, DB>)
-> crate::QueryResult<()> {
pass.push_sql(" ROWS ");
Ok(())
}
}simple_frame_expr!(
92 Rows, " ROWS ");
97#[doc = r" Groups frame mode"]
#[doc = r""]
#[doc = r" This options specifies that the offset starts/ends"]
#[doc = r" a certain number of peer groups before or after"]
#[doc = r" the current row. A peer group is a set of rows that are"]
#[doc = r" equivalent in the `ORDER BY` ordering"]
#[doc = r""]
#[doc = r" There must be a `ORDER BY` clause set via `window_order`"]
#[doc = r" for the current window function call"]
pub struct Groups;
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl diesel::query_builder::QueryId for Groups {
type QueryId = Groups<>;
const HAS_STATIC_QUERY_ID: bool = true;
const IS_WINDOW_FUNCTION: bool = false;
}
};
#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for Groups { }
#[automatically_derived]
impl ::core::clone::Clone for Groups {
#[inline]
fn clone(&self) -> Groups { *self }
}
#[automatically_derived]
impl ::core::marker::Copy for Groups { }
#[automatically_derived]
impl ::core::fmt::Debug for Groups {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f, "Groups")
}
}
impl<DB> QueryFragment<DB> for Groups where DB: crate::backend::Backend,
Self: QueryFragment<DB, DB::WindowFrameClauseGroupSupport> {
fn walk_ast<'b>(&'b self, pass: crate::query_builder::AstPass<'_, 'b, DB>)
-> crate::QueryResult<()> {
<Self as
QueryFragment<DB,
DB::WindowFrameClauseGroupSupport>>::walk_ast(self, pass)
}
}
impl<DB>
QueryFragment<DB,
sql_dialect::window_frame_clause_group_support::IsoGroupWindowFrameUnit>
for Groups where
DB: crate::backend::Backend<WindowFrameClauseGroupSupport =
sql_dialect::window_frame_clause_group_support::IsoGroupWindowFrameUnit> {
fn walk_ast<'b>(&'b self,
mut pass: crate::query_builder::AstPass<'_, 'b, DB>)
-> crate::QueryResult<()> {
pass.push_sql(" GROUPS ");
Ok(())
}
}simple_frame_expr_with_bound!(
98 Groups,
108 WindowFrameClauseGroupSupport,
109 sql_dialect::window_frame_clause_group_support::IsoGroupWindowFrameUnit,
110 " GROUPS "
111);
112
113#[doc = r" A `UNBOUNDED PRECEDING` frame bound"]
#[doc = r""]
#[doc = r" This bound specifies that the frame starts with"]
#[doc = r" the first row of the partition"]
#[doc = r""]
#[doc = r" This option can be used as frame start"]
pub struct UnboundedPreceding;
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl diesel::query_builder::QueryId for UnboundedPreceding {
type QueryId = UnboundedPreceding<>;
const HAS_STATIC_QUERY_ID: bool = true;
const IS_WINDOW_FUNCTION: bool = false;
}
};
#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for UnboundedPreceding { }
#[automatically_derived]
impl ::core::clone::Clone for UnboundedPreceding {
#[inline]
fn clone(&self) -> UnboundedPreceding { *self }
}
#[automatically_derived]
impl ::core::marker::Copy for UnboundedPreceding { }
#[automatically_derived]
impl ::core::fmt::Debug for UnboundedPreceding {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f, "UnboundedPreceding")
}
}
impl<DB> QueryFragment<DB> for UnboundedPreceding where
DB: crate::backend::Backend {
fn walk_ast<'b>(&'b self,
mut pass: crate::query_builder::AstPass<'_, 'b, DB>)
-> crate::QueryResult<()> {
pass.push_sql("UNBOUNDED PRECEDING ");
Ok(())
}
}simple_frame_expr!(
115 UnboundedPreceding, "UNBOUNDED PRECEDING ");
122#[doc = r" A `CURRENT ROW` frame bound"]
#[doc = r""]
#[doc = r" For the `RANGE` and `GROUP` frame mode this bound"]
#[doc = r" specifies that the current frame starts with the current"]
#[doc = r" rows first peer groups row. A peer group is defined as a"]
#[doc = r" set of rows with an equivalent `ORDER BY` ordering."]
#[doc = r""]
#[doc = r" For the `ROWS` mode `CURRENT ROW` simply means the current"]
#[doc = r" row"]
#[doc = r""]
#[doc = r" This option can be used as frame start and end"]
pub struct CurrentRow;
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl diesel::query_builder::QueryId for CurrentRow {
type QueryId = CurrentRow<>;
const HAS_STATIC_QUERY_ID: bool = true;
const IS_WINDOW_FUNCTION: bool = false;
}
};
#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for CurrentRow { }
#[automatically_derived]
impl ::core::clone::Clone for CurrentRow {
#[inline]
fn clone(&self) -> CurrentRow { *self }
}
#[automatically_derived]
impl ::core::marker::Copy for CurrentRow { }
#[automatically_derived]
impl ::core::fmt::Debug for CurrentRow {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f, "CurrentRow")
}
}
impl<DB> QueryFragment<DB> for CurrentRow where DB: crate::backend::Backend {
fn walk_ast<'b>(&'b self,
mut pass: crate::query_builder::AstPass<'_, 'b, DB>)
-> crate::QueryResult<()> {
pass.push_sql("CURRENT ROW ");
Ok(())
}
}simple_frame_expr!(
123 CurrentRow, "CURRENT ROW ");
135#[doc = r" A `UNBOUNDED FOLLOWING` frame bound"]
#[doc = r""]
#[doc = r" This bound specifies that the frame ends with"]
#[doc = r" the last row of the partition"]
#[doc = r""]
#[doc = r" This option can be used as frame end"]
pub struct UnboundedFollowing;
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl diesel::query_builder::QueryId for UnboundedFollowing {
type QueryId = UnboundedFollowing<>;
const HAS_STATIC_QUERY_ID: bool = true;
const IS_WINDOW_FUNCTION: bool = false;
}
};
#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for UnboundedFollowing { }
#[automatically_derived]
impl ::core::clone::Clone for UnboundedFollowing {
#[inline]
fn clone(&self) -> UnboundedFollowing { *self }
}
#[automatically_derived]
impl ::core::marker::Copy for UnboundedFollowing { }
#[automatically_derived]
impl ::core::fmt::Debug for UnboundedFollowing {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f, "UnboundedFollowing")
}
}
impl<DB> QueryFragment<DB> for UnboundedFollowing where
DB: crate::backend::Backend {
fn walk_ast<'b>(&'b self,
mut pass: crate::query_builder::AstPass<'_, 'b, DB>)
-> crate::QueryResult<()> {
pass.push_sql("UNBOUNDED FOLLOWING ");
Ok(())
}
}simple_frame_expr!(
136 UnboundedFollowing, "UNBOUNDED FOLLOWING ");
143
144#[doc = r" Exclude the current row from the window frame"]
pub struct ExcludeCurrentRow;
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl diesel::query_builder::QueryId for ExcludeCurrentRow {
type QueryId = ExcludeCurrentRow<>;
const HAS_STATIC_QUERY_ID: bool = true;
const IS_WINDOW_FUNCTION: bool = false;
}
};
#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for ExcludeCurrentRow { }
#[automatically_derived]
impl ::core::clone::Clone for ExcludeCurrentRow {
#[inline]
fn clone(&self) -> ExcludeCurrentRow { *self }
}
#[automatically_derived]
impl ::core::marker::Copy for ExcludeCurrentRow { }
#[automatically_derived]
impl ::core::fmt::Debug for ExcludeCurrentRow {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f, "ExcludeCurrentRow")
}
}
impl<DB> QueryFragment<DB> for ExcludeCurrentRow where
DB: crate::backend::Backend,
Self: QueryFragment<DB, DB::WindowFrameExclusionSupport> {
fn walk_ast<'b>(&'b self, pass: crate::query_builder::AstPass<'_, 'b, DB>)
-> crate::QueryResult<()> {
<Self as
QueryFragment<DB,
DB::WindowFrameExclusionSupport>>::walk_ast(self, pass)
}
}
impl<DB>
QueryFragment<DB,
sql_dialect::window_frame_exclusion_support::FrameExclusionSupport> for
ExcludeCurrentRow where
DB: crate::backend::Backend<WindowFrameExclusionSupport =
sql_dialect::window_frame_exclusion_support::FrameExclusionSupport> {
fn walk_ast<'b>(&'b self,
mut pass: crate::query_builder::AstPass<'_, 'b, DB>)
-> crate::QueryResult<()> {
pass.push_sql("EXCLUDE CURRENT ROW ");
Ok(())
}
}simple_frame_expr_with_bound!(
146 ExcludeCurrentRow,
148 WindowFrameExclusionSupport,
149 sql_dialect::window_frame_exclusion_support::FrameExclusionSupport,
150 "EXCLUDE CURRENT ROW "
151);
152#[doc = r" Exclude the current peer group from the window frame"]
#[doc = r""]
#[doc = r" A peer group is a set of rows with an equivalent `ORDER BY`"]
#[doc = r" ordering"]
pub struct ExcludeGroup;
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl diesel::query_builder::QueryId for ExcludeGroup {
type QueryId = ExcludeGroup<>;
const HAS_STATIC_QUERY_ID: bool = true;
const IS_WINDOW_FUNCTION: bool = false;
}
};
#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for ExcludeGroup { }
#[automatically_derived]
impl ::core::clone::Clone for ExcludeGroup {
#[inline]
fn clone(&self) -> ExcludeGroup { *self }
}
#[automatically_derived]
impl ::core::marker::Copy for ExcludeGroup { }
#[automatically_derived]
impl ::core::fmt::Debug for ExcludeGroup {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f, "ExcludeGroup")
}
}
impl<DB> QueryFragment<DB> for ExcludeGroup where DB: crate::backend::Backend,
Self: QueryFragment<DB, DB::WindowFrameExclusionSupport> {
fn walk_ast<'b>(&'b self, pass: crate::query_builder::AstPass<'_, 'b, DB>)
-> crate::QueryResult<()> {
<Self as
QueryFragment<DB,
DB::WindowFrameExclusionSupport>>::walk_ast(self, pass)
}
}
impl<DB>
QueryFragment<DB,
sql_dialect::window_frame_exclusion_support::FrameExclusionSupport> for
ExcludeGroup where
DB: crate::backend::Backend<WindowFrameExclusionSupport =
sql_dialect::window_frame_exclusion_support::FrameExclusionSupport> {
fn walk_ast<'b>(&'b self,
mut pass: crate::query_builder::AstPass<'_, 'b, DB>)
-> crate::QueryResult<()> {
pass.push_sql("EXCLUDE GROUP ");
Ok(())
}
}simple_frame_expr_with_bound!(
153 ExcludeGroup,
158 WindowFrameExclusionSupport,
159 sql_dialect::window_frame_exclusion_support::FrameExclusionSupport,
160 "EXCLUDE GROUP "
161);
162#[doc = r" Exclude any peers, but not the current row from the window frame"]
#[doc = r""]
#[doc = r" This excludes any row with an equivalent `ORDER BY` ordering"]
#[doc = r" to the current row from the frame window"]
pub struct ExcludeTies;
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl diesel::query_builder::QueryId for ExcludeTies {
type QueryId = ExcludeTies<>;
const HAS_STATIC_QUERY_ID: bool = true;
const IS_WINDOW_FUNCTION: bool = false;
}
};
#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for ExcludeTies { }
#[automatically_derived]
impl ::core::clone::Clone for ExcludeTies {
#[inline]
fn clone(&self) -> ExcludeTies { *self }
}
#[automatically_derived]
impl ::core::marker::Copy for ExcludeTies { }
#[automatically_derived]
impl ::core::fmt::Debug for ExcludeTies {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f, "ExcludeTies")
}
}
impl<DB> QueryFragment<DB> for ExcludeTies where DB: crate::backend::Backend,
Self: QueryFragment<DB, DB::WindowFrameExclusionSupport> {
fn walk_ast<'b>(&'b self, pass: crate::query_builder::AstPass<'_, 'b, DB>)
-> crate::QueryResult<()> {
<Self as
QueryFragment<DB,
DB::WindowFrameExclusionSupport>>::walk_ast(self, pass)
}
}
impl<DB>
QueryFragment<DB,
sql_dialect::window_frame_exclusion_support::FrameExclusionSupport> for
ExcludeTies where
DB: crate::backend::Backend<WindowFrameExclusionSupport =
sql_dialect::window_frame_exclusion_support::FrameExclusionSupport> {
fn walk_ast<'b>(&'b self,
mut pass: crate::query_builder::AstPass<'_, 'b, DB>)
-> crate::QueryResult<()> {
pass.push_sql("EXCLUDE TIES ");
Ok(())
}
}simple_frame_expr_with_bound!(
163 ExcludeTies,
168 WindowFrameExclusionSupport,
169 sql_dialect::window_frame_exclusion_support::FrameExclusionSupport,
170 "EXCLUDE TIES "
171);
172#[doc = r" Exclude no rows from the frame windows"]
#[doc = r""]
#[doc = r" This is the default behaviour if not specified"]
pub struct ExcludeNoOthers;
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl diesel::query_builder::QueryId for ExcludeNoOthers {
type QueryId = ExcludeNoOthers<>;
const HAS_STATIC_QUERY_ID: bool = true;
const IS_WINDOW_FUNCTION: bool = false;
}
};
#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for ExcludeNoOthers { }
#[automatically_derived]
impl ::core::clone::Clone for ExcludeNoOthers {
#[inline]
fn clone(&self) -> ExcludeNoOthers { *self }
}
#[automatically_derived]
impl ::core::marker::Copy for ExcludeNoOthers { }
#[automatically_derived]
impl ::core::fmt::Debug for ExcludeNoOthers {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f, "ExcludeNoOthers")
}
}
impl<DB> QueryFragment<DB> for ExcludeNoOthers where
DB: crate::backend::Backend,
Self: QueryFragment<DB, DB::WindowFrameExclusionSupport> {
fn walk_ast<'b>(&'b self, pass: crate::query_builder::AstPass<'_, 'b, DB>)
-> crate::QueryResult<()> {
<Self as
QueryFragment<DB,
DB::WindowFrameExclusionSupport>>::walk_ast(self, pass)
}
}
impl<DB>
QueryFragment<DB,
sql_dialect::window_frame_exclusion_support::FrameExclusionSupport> for
ExcludeNoOthers where
DB: crate::backend::Backend<WindowFrameExclusionSupport =
sql_dialect::window_frame_exclusion_support::FrameExclusionSupport> {
fn walk_ast<'b>(&'b self,
mut pass: crate::query_builder::AstPass<'_, 'b, DB>)
-> crate::QueryResult<()> {
pass.push_sql("EXCLUDE NO OTHERS ");
Ok(())
}
}simple_frame_expr_with_bound!(
173 ExcludeNoOthers,
177 WindowFrameExclusionSupport,
178 sql_dialect::window_frame_exclusion_support::FrameExclusionSupport,
179 "EXCLUDE NO OTHERS "
180);
181
182#[derive(#[automatically_derived]
impl<T: ::core::clone::Clone> ::core::clone::Clone for OffsetPreceding<T> {
#[inline]
fn clone(&self) -> OffsetPreceding<T> {
OffsetPreceding(::core::clone::Clone::clone(&self.0))
}
}Clone, #[automatically_derived]
impl<T: ::core::marker::Copy> ::core::marker::Copy for OffsetPreceding<T> { }Copy, #[automatically_derived]
impl<T: ::core::fmt::Debug> ::core::fmt::Debug for OffsetPreceding<T> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"OffsetPreceding", &&self.0)
}
}Debug)]
186pub struct OffsetPreceding<T = u64>(T);
187
188impl QueryId for OffsetPreceding {
191 type QueryId = ();
192
193 const HAS_STATIC_QUERY_ID: bool = false;
197}
198
199impl<DB> QueryFragment<DB> for OffsetPreceding
200where
201 DB: crate::backend::Backend,
202{
203 fn walk_ast<'b>(
204 &'b self,
205 mut pass: crate::query_builder::AstPass<'_, 'b, DB>,
206 ) -> crate::QueryResult<()> {
207 pass.push_sql(&self.0.to_string());
210 pass.push_sql(" PRECEDING ");
211 Ok(())
212 }
213}
214
215#[derive(#[automatically_derived]
impl<I: ::core::clone::Clone> ::core::clone::Clone for OffsetFollowing<I> {
#[inline]
fn clone(&self) -> OffsetFollowing<I> {
OffsetFollowing(::core::clone::Clone::clone(&self.0))
}
}Clone, #[automatically_derived]
impl<I: ::core::marker::Copy> ::core::marker::Copy for OffsetFollowing<I> { }Copy, #[automatically_derived]
impl<I: ::core::fmt::Debug> ::core::fmt::Debug for OffsetFollowing<I> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"OffsetFollowing", &&self.0)
}
}Debug)]
219pub struct OffsetFollowing<I = u64>(I);
220
221impl QueryId for OffsetFollowing {
224 type QueryId = ();
225
226 const HAS_STATIC_QUERY_ID: bool = false;
230}
231
232impl<DB> QueryFragment<DB> for OffsetFollowing
233where
234 DB: crate::backend::Backend,
235{
236 fn walk_ast<'b>(
237 &'b self,
238 mut pass: crate::query_builder::AstPass<'_, 'b, DB>,
239 ) -> crate::QueryResult<()> {
240 pass.push_sql(&self.0.to_string());
243 pass.push_sql(" FOLLOWING ");
244 Ok(())
245 }
246}
247
248pub trait FrameDsl<F> {
249 type Output;
250
251 fn frame(self, expr: F) -> Self::Output;
252}
253
254#[diagnostic::on_unimplemented(
255 message = "`Groups` frame clauses require a ordered window function",
256 note = "call `.window_order(some_column)` first"
257)]
258pub trait ValidFrameClause<O> {}
259
260impl<O, Kind, Start, End, Exclusion> ValidFrameClause<O>
261 for BetweenFrame<Kind, Start, End, Exclusion>
262where
263 Kind: ValidFrameClause<O>,
264{
265}
266impl<O, Kind, Start, Exclusion> ValidFrameClause<O> for StartFrame<Kind, Start, Exclusion> where
267 Kind: ValidFrameClause<O>
268{
269}
270impl<O> ValidFrameClause<O> for Rows {}
271impl<O> ValidFrameClause<O> for Range {}
272impl<O> ValidFrameClause<Order<O, true>> for Groups {}
273
274impl<E, Fn, Filter, Frame, Partition, Order> FrameDsl<E>
275 for AggregateExpression<Fn, NoPrefix, NoOrder, Filter, OverClause<Partition, Order, Frame>>
276where
277 E: FrameClauseExpression,
278 E: ValidFrameClause<Order>,
279 Filter: ValidAggregateFilterForWindow<Fn, OverClause<Partition, Order, FrameClause<E>>>,
280{
281 type Output = AggregateExpression<
282 Fn,
283 NoPrefix,
284 NoOrder,
285 Filter,
286 OverClause<Partition, Order, FrameClause<E>>,
287 >;
288
289 fn frame(self, expr: E) -> Self::Output {
290 AggregateExpression {
291 prefix: self.prefix,
292 function: self.function,
293 order: self.order,
294 filter: self.filter,
295 window: OverClause {
296 partition_by: self.window.partition_by,
297 order: self.window.order,
298 frame_clause: FrameClause(expr),
299 },
300 }
301 }
302}
303
304impl<E, Fn, Filter> FrameDsl<E> for AggregateExpression<Fn, NoPrefix, NoOrder, Filter, NoWindow>
305where
306 E: FrameClauseExpression,
307 E: ValidFrameClause<NoOrder>,
308 Filter: ValidAggregateFilterForWindow<Fn, OverClause<NoPartition, NoOrder, FrameClause<E>>>,
309{
310 type Output = AggregateExpression<
311 Fn,
312 NoPrefix,
313 NoOrder,
314 Filter,
315 OverClause<NoPartition, NoOrder, FrameClause<E>>,
316 >;
317
318 fn frame(self, expr: E) -> Self::Output {
319 AggregateExpression {
320 prefix: self.prefix,
321 function: self.function,
322 order: self.order,
323 filter: self.filter,
324 window: OverClause {
325 partition_by: NoPartition,
326 order: NoOrder,
327 frame_clause: FrameClause(expr),
328 },
329 }
330 }
331}
332
333impl<E, Fn> FrameDsl<E> for Fn
334where
335 Fn: IsWindowFunction,
336 E: FrameClauseExpression,
337 E: ValidFrameClause<NoOrder>,
338{
339 type Output = AggregateExpression<
340 Fn,
341 NoPrefix,
342 NoOrder,
343 NoFilter,
344 OverClause<NoPartition, NoOrder, FrameClause<E>>,
345 >;
346
347 fn frame(self, expr: E) -> Self::Output {
348 AggregateExpression {
349 prefix: NoPrefix,
350 function: self,
351 order: NoOrder,
352 filter: NoFilter,
353 window: OverClause {
354 partition_by: NoPartition,
355 order: NoOrder,
356 frame_clause: FrameClause(expr),
357 },
358 }
359 }
360}
361
362pub trait FrameClauseExpression {}
363
364pub trait FrameClauseStartBound: Sealed {}
369
370pub trait FrameClauseEndBound: Sealed {}
375
376impl FrameClauseEndBound for UnboundedFollowing {}
377impl Sealed for UnboundedFollowing {}
378impl FrameClauseStartBound for UnboundedPreceding {}
379impl Sealed for UnboundedPreceding {}
380impl FrameClauseEndBound for CurrentRow {}
381impl FrameClauseStartBound for CurrentRow {}
382impl Sealed for CurrentRow {}
383impl FrameClauseEndBound for OffsetFollowing {}
384impl Sealed for OffsetFollowing {}
385impl FrameClauseStartBound for OffsetPreceding {}
386impl Sealed for OffsetPreceding {}
387
388pub trait FrameClauseExclusion: Sealed {}
393
394impl FrameClauseExclusion for ExcludeGroup {}
395impl Sealed for ExcludeGroup {}
396impl FrameClauseExclusion for ExcludeNoOthers {}
397impl Sealed for ExcludeNoOthers {}
398impl FrameClauseExclusion for ExcludeTies {}
399impl Sealed for ExcludeTies {}
400impl FrameClauseExclusion for ExcludeCurrentRow {}
401impl Sealed for ExcludeCurrentRow {}
402
403pub trait FrameBoundDsl {
405 fn preceding(self) -> OffsetPreceding;
407
408 fn following(self) -> OffsetFollowing;
410}
411
412impl FrameBoundDsl for u64 {
413 fn preceding(self) -> OffsetPreceding {
414 OffsetPreceding(self)
415 }
416
417 fn following(self) -> OffsetFollowing {
418 OffsetFollowing(self)
419 }
420}
421pub struct NoExclusion;
#[automatically_derived]
impl ::core::fmt::Debug for NoExclusion {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f, "NoExclusion")
}
}
#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for NoExclusion { }
#[automatically_derived]
impl ::core::clone::Clone for NoExclusion {
#[inline]
fn clone(&self) -> NoExclusion { *self }
}
#[automatically_derived]
impl ::core::marker::Copy for NoExclusion { }
const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl diesel::query_builder::QueryId for NoExclusion {
type QueryId = NoExclusion<>;
const HAS_STATIC_QUERY_ID: bool = true;
const IS_WINDOW_FUNCTION: bool = false;
}
};
impl<DB> crate::query_builder::QueryFragment<DB> for NoExclusion 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!(NoExclusion);
428
429#[derive(const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl<Kind: diesel::query_builder::QueryId,
Start: diesel::query_builder::QueryId,
Exclusion: diesel::query_builder::QueryId>
diesel::query_builder::QueryId for
StartFrame<Kind, Start, Exclusion> {
type QueryId =
StartFrame<<Kind as diesel::query_builder::QueryId>::QueryId,
<Start as diesel::query_builder::QueryId>::QueryId,
<Exclusion as diesel::query_builder::QueryId>::QueryId>;
const HAS_STATIC_QUERY_ID: bool =
<Kind as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<Start as
diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
<Exclusion as
diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
true;
const IS_WINDOW_FUNCTION: bool =
<Kind as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
||
<Start as
diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
<Exclusion as
diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
false;
}
};QueryId, #[automatically_derived]
impl<Kind: ::core::marker::Copy, Start: ::core::marker::Copy,
Exclusion: ::core::marker::Copy> ::core::marker::Copy for
StartFrame<Kind, Start, Exclusion> {
}Copy, #[automatically_derived]
impl<Kind: ::core::clone::Clone, Start: ::core::clone::Clone,
Exclusion: ::core::clone::Clone> ::core::clone::Clone for
StartFrame<Kind, Start, Exclusion> {
#[inline]
fn clone(&self) -> StartFrame<Kind, Start, Exclusion> {
StartFrame {
kind: ::core::clone::Clone::clone(&self.kind),
start: ::core::clone::Clone::clone(&self.start),
exclusion: ::core::clone::Clone::clone(&self.exclusion),
}
}
}Clone, #[automatically_derived]
impl<Kind: ::core::fmt::Debug, Start: ::core::fmt::Debug,
Exclusion: ::core::fmt::Debug> ::core::fmt::Debug for
StartFrame<Kind, Start, Exclusion> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f, "StartFrame",
"kind", &self.kind, "start", &self.start, "exclusion",
&&self.exclusion)
}
}Debug)]
430pub struct StartFrame<Kind, Start, Exclusion = NoExclusion> {
431 kind: Kind,
432 start: Start,
433 exclusion: Exclusion,
434}
435
436impl<Kind, Start, Exclusion, DB> QueryFragment<DB> for StartFrame<Kind, Start, Exclusion>
437where
438 Kind: QueryFragment<DB>,
439 Start: QueryFragment<DB>,
440 Exclusion: QueryFragment<DB>,
441 DB: crate::backend::Backend,
442{
443 fn walk_ast<'b>(
444 &'b self,
445 mut pass: crate::query_builder::AstPass<'_, 'b, DB>,
446 ) -> crate::QueryResult<()> {
447 self.kind.walk_ast(pass.reborrow())?;
448 self.start.walk_ast(pass.reborrow())?;
449 self.exclusion.walk_ast(pass.reborrow())?;
450 Ok(())
451 }
452}
453
454impl<Kind, Start, Exclusion> FrameClauseExpression for StartFrame<Kind, Start, Exclusion> {}
455
456#[derive(const _: () =
{
use diesel;
#[allow(non_camel_case_types)]
impl<Kind: diesel::query_builder::QueryId,
Start: diesel::query_builder::QueryId,
End: diesel::query_builder::QueryId,
Exclusion: diesel::query_builder::QueryId>
diesel::query_builder::QueryId for
BetweenFrame<Kind, Start, End, Exclusion> {
type QueryId =
BetweenFrame<<Kind as
diesel::query_builder::QueryId>::QueryId,
<Start as diesel::query_builder::QueryId>::QueryId,
<End as diesel::query_builder::QueryId>::QueryId,
<Exclusion as diesel::query_builder::QueryId>::QueryId>;
const HAS_STATIC_QUERY_ID: bool =
<Kind as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<Start as
diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
<End as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
&&
<Exclusion as
diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
true;
const IS_WINDOW_FUNCTION: bool =
<Kind as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
||
<Start as
diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
<End as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
||
<Exclusion as
diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
false;
}
};QueryId, #[automatically_derived]
impl<Kind: ::core::marker::Copy, Start: ::core::marker::Copy,
End: ::core::marker::Copy, Exclusion: ::core::marker::Copy>
::core::marker::Copy for BetweenFrame<Kind, Start, End, Exclusion> {
}Copy, #[automatically_derived]
impl<Kind: ::core::clone::Clone, Start: ::core::clone::Clone,
End: ::core::clone::Clone, Exclusion: ::core::clone::Clone>
::core::clone::Clone for BetweenFrame<Kind, Start, End, Exclusion> {
#[inline]
fn clone(&self) -> BetweenFrame<Kind, Start, End, Exclusion> {
BetweenFrame {
kind: ::core::clone::Clone::clone(&self.kind),
start: ::core::clone::Clone::clone(&self.start),
end: ::core::clone::Clone::clone(&self.end),
exclusion: ::core::clone::Clone::clone(&self.exclusion),
}
}
}Clone, #[automatically_derived]
impl<Kind: ::core::fmt::Debug, Start: ::core::fmt::Debug,
End: ::core::fmt::Debug, Exclusion: ::core::fmt::Debug> ::core::fmt::Debug
for BetweenFrame<Kind, Start, End, Exclusion> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field4_finish(f, "BetweenFrame",
"kind", &self.kind, "start", &self.start, "end", &self.end,
"exclusion", &&self.exclusion)
}
}Debug)]
457pub struct BetweenFrame<Kind, Start, End, Exclusion = NoExclusion> {
458 kind: Kind,
459 start: Start,
460 end: End,
461 exclusion: Exclusion,
462}
463
464impl<Kind, Start, End, Exclusion, DB> QueryFragment<DB>
465 for BetweenFrame<Kind, Start, End, Exclusion>
466where
467 Kind: QueryFragment<DB>,
468 Start: QueryFragment<DB>,
469 End: QueryFragment<DB>,
470 Exclusion: QueryFragment<DB>,
471 DB: crate::backend::Backend,
472{
473 fn walk_ast<'b>(
474 &'b self,
475 mut pass: crate::query_builder::AstPass<'_, 'b, DB>,
476 ) -> crate::QueryResult<()> {
477 self.kind.walk_ast(pass.reborrow())?;
478 pass.push_sql(" BETWEEN ");
479 self.start.walk_ast(pass.reborrow())?;
480 pass.push_sql(" AND ");
481 self.end.walk_ast(pass.reborrow())?;
482 self.exclusion.walk_ast(pass.reborrow())?;
483 Ok(())
484 }
485}
486
487impl<Kind, Start, End, Exclusion> FrameClauseExpression
488 for BetweenFrame<Kind, Start, End, Exclusion>
489{
490}
491
492pub trait FrameClauseDslHelper: Sized {}
493
494pub trait FrameClauseDsl: FrameClauseDslHelper {
496 fn frame_start_with<E>(self, start: E) -> super::dsl::FrameStartWith<Self, E>
498 where
499 E: FrameClauseStartBound,
500 {
501 StartFrame {
502 kind: self,
503 start,
504 exclusion: NoExclusion,
505 }
506 }
507
508 fn frame_start_with_exclusion<E1, E2>(
510 self,
511 start: E1,
512 exclusion: E2,
513 ) -> super::dsl::FrameStartWithExclusion<Self, E1, E2>
514 where
515 E1: FrameClauseStartBound,
516 E2: FrameClauseExclusion,
517 {
518 StartFrame {
519 kind: self,
520 start,
521 exclusion,
522 }
523 }
524
525 fn frame_between<E1, E2>(self, start: E1, end: E2) -> super::dsl::FrameBetween<Self, E1, E2>
527 where
528 E1: FrameClauseStartBound,
529 E2: FrameClauseEndBound,
530 {
531 BetweenFrame {
532 kind: self,
533 start,
534 end,
535 exclusion: NoExclusion,
536 }
537 }
538
539 fn frame_between_with_exclusion<E1, E2, E3>(
541 self,
542 start: E1,
543 end: E2,
544 exclusion: E3,
545 ) -> super::dsl::FrameBetweenWithExclusion<Self, E1, E2, E3>
546 where
547 E1: FrameClauseStartBound,
548 E2: FrameClauseEndBound,
549 E3: FrameClauseExclusion,
550 {
551 BetweenFrame {
552 kind: self,
553 start,
554 end,
555 exclusion,
556 }
557 }
558}
559
560impl<T> FrameClauseDsl for T where T: FrameClauseDslHelper {}
561
562impl FrameClauseDslHelper for Range {}
563impl FrameClauseDslHelper for Rows {}
564impl FrameClauseDslHelper for Groups {}
565
566pub trait Sealed {}