Struct sea_query::query::WindowStatement

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

Implementationsยง

Construct a new WindowStatement

Construct a new WindowStatement with PARTITION BY column

Construct a new WindowStatement with PARTITION BY custom

Construct a new WindowStatement with ORDER BY column

Construct a new WindowStatement with ORDER BY custom

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""#
);

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""#
);

frame clause

Trait Implementationsยง

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the โ€œdefault valueโ€ for a type. Read more
Clear order expressions
Order by column. Read more
Order by SimpleExpr.
Order by custom string.
Order by vector of columns.
Order by column with nulls order option. Read more
Order by SimpleExpr with nulls order option.
Order by custom string with nulls order option.
Order by vector of columns with nulls order option.
Partition by column.
Partition by custom string.
Partition by vector of columns.

Auto Trait Implementationsยง

Blanket Implementationsยง

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.