Struct sea_query::query::WindowStatement

source ยท
pub struct WindowStatement { /* private fields */ }
Expand description

Implementationsยง

sourceยง

impl WindowStatement

source

pub fn new() -> Self

Construct a new WindowStatement

source

pub fn take(&mut self) -> Self

source

pub fn partition_by<T>(col: T) -> Self
where T: IntoColumnRef,

Construct a new WindowStatement with PARTITION BY column

source

pub fn partition_by_custom<T>(col: T) -> Self
where T: ToString,

Construct a new WindowStatement with PARTITION BY custom

source

pub fn frame_start(&mut self, type: FrameType, start: Frame) -> &mut Self

frame clause for frame_start

Examples:
use sea_query::{tests_cfg::*, *};

let query = Query::select()
    .from(Char::Table)
    .expr_window_as(
        Expr::col(Char::Character),
        WindowStatement::partition_by(Char::FontSize)
            .frame_start(FrameType::Rows, Frame::UnboundedPreceding)
            .take(),
        Alias::new("C"))
    .to_owned();

assert_eq!(
    query.to_string(MysqlQueryBuilder),
    r#"SELECT `character` OVER ( PARTITION BY `font_size` ROWS UNBOUNDED PRECEDING ) AS `C` FROM `character`"#
);
assert_eq!(
    query.to_string(PostgresQueryBuilder),
    r#"SELECT "character" OVER ( PARTITION BY "font_size" ROWS UNBOUNDED PRECEDING ) AS "C" FROM "character""#
);
assert_eq!(
    query.to_string(SqliteQueryBuilder),
    r#"SELECT "character" OVER ( PARTITION BY "font_size" ROWS UNBOUNDED PRECEDING ) AS "C" FROM "character""#
);
source

pub fn frame_between( &mut self, type: FrameType, start: Frame, end: Frame ) -> &mut Self

frame clause for BETWEEN frame_start AND frame_end

Examples:
use sea_query::{tests_cfg::*, *};

let query = Query::select()
    .from(Char::Table)
    .expr_window_as(
        Expr::col(Char::Character),
        WindowStatement::partition_by(Char::FontSize)
            .frame_between(FrameType::Rows, Frame::UnboundedPreceding, Frame::UnboundedFollowing)
            .take(),
        Alias::new("C"))
    .to_owned();

assert_eq!(
    query.to_string(MysqlQueryBuilder),
    r#"SELECT `character` OVER ( PARTITION BY `font_size` ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS `C` FROM `character`"#
);
assert_eq!(
    query.to_string(PostgresQueryBuilder),
    r#"SELECT "character" OVER ( PARTITION BY "font_size" ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS "C" FROM "character""#
);
assert_eq!(
    query.to_string(SqliteQueryBuilder),
    r#"SELECT "character" OVER ( PARTITION BY "font_size" ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS "C" FROM "character""#
);
source

pub fn frame( &mut self, type: FrameType, start: Frame, end: Option<Frame> ) -> &mut Self

frame clause

sourceยง

impl WindowStatement

Trait Implementationsยง

sourceยง

impl Clone for WindowStatement

sourceยง

fn clone(&self) -> WindowStatement

Returns a copy of the value. Read more
1.0.0 ยท sourceยง

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
sourceยง

impl Debug for WindowStatement

sourceยง

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
sourceยง

impl Default for WindowStatement

sourceยง

fn default() -> WindowStatement

Returns the โ€œdefault valueโ€ for a type. Read more
sourceยง

impl OrderedStatement for WindowStatement

sourceยง

fn clear_order_by(&mut self) -> &mut Self

Clear order expressions
sourceยง

fn order_by<T>(&mut self, col: T, order: Order) -> &mut Self
where T: IntoColumnRef,

Order by column. Read more
sourceยง

fn order_by_expr(&mut self, expr: SimpleExpr, order: Order) -> &mut Self

Order by SimpleExpr.
sourceยง

fn order_by_customs<I, T>(&mut self, cols: I) -> &mut Self
where T: ToString, I: IntoIterator<Item = (T, Order)>,

Order by custom string.
sourceยง

fn order_by_columns<I, T>(&mut self, cols: I) -> &mut Self
where T: IntoColumnRef, I: IntoIterator<Item = (T, Order)>,

Order by vector of columns.
sourceยง

fn order_by_with_nulls<T>( &mut self, col: T, order: Order, nulls: NullOrdering ) -> &mut Self
where T: IntoColumnRef,

Order by column with nulls order option. Read more
sourceยง

fn order_by_expr_with_nulls( &mut self, expr: SimpleExpr, order: Order, nulls: NullOrdering ) -> &mut Self

Order by SimpleExpr with nulls order option.
sourceยง

fn order_by_customs_with_nulls<I, T>(&mut self, cols: I) -> &mut Self
where T: ToString, I: IntoIterator<Item = (T, Order, NullOrdering)>,

Order by custom string with nulls order option.
sourceยง

fn order_by_columns_with_nulls<I, T>(&mut self, cols: I) -> &mut Self
where T: IntoColumnRef, I: IntoIterator<Item = (T, Order, NullOrdering)>,

Order by vector of columns with nulls order option.
sourceยง

impl OverStatement for WindowStatement

sourceยง

fn partition_by<T>(&mut self, col: T) -> &mut Self
where T: IntoColumnRef,

Partition by column.
sourceยง

fn partition_by_customs<I, T>(&mut self, cols: I) -> &mut Self
where T: ToString, I: IntoIterator<Item = T>,

Partition by custom string.
sourceยง

fn partition_by_columns<I, T>(&mut self, cols: I) -> &mut Self
where T: IntoColumnRef, I: IntoIterator<Item = T>,

Partition by vector of columns.
sourceยง

impl PartialEq for WindowStatement

sourceยง

fn eq(&self, other: &WindowStatement) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 ยท sourceยง

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
sourceยง

impl StructuralPartialEq for WindowStatement

Auto Trait Implementationsยง

Blanket Implementationsยง

sourceยง

impl<T> Any for T
where T: 'static + ?Sized,

sourceยง

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
sourceยง

impl<T> Borrow<T> for T
where T: ?Sized,

sourceยง

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
sourceยง

impl<T> BorrowMut<T> for T
where T: ?Sized,

sourceยง

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
sourceยง

impl<T> From<T> for T

sourceยง

fn from(t: T) -> T

Returns the argument unchanged.

sourceยง

impl<T, U> Into<U> for T
where U: From<T>,

sourceยง

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

sourceยง

impl<T> ToOwned for T
where T: Clone,

ยง

type Owned = T

The resulting type after obtaining ownership.
sourceยง

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
sourceยง

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
sourceยง

impl<T, U> TryFrom<U> for T
where U: Into<T>,

ยง

type Error = Infallible

The type returned in the event of a conversion error.
sourceยง

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
sourceยง

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

ยง

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
sourceยง

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.