sea_query::query

Struct 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

source

pub fn add_order_by(&mut self, order: OrderExpr) -> &mut Self

source

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

source

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

source

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

source

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

source

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

source

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

source

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

source

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

source

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

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

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> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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,

source§

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>,

source§

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>,

source§

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.