Struct sea_query::query::DeleteStatement[][src]

pub struct DeleteStatement { /* fields omitted */ }
Expand description

Delete existing rows from the table

Examples

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

let query = Query::delete()
    .from_table(Glyph::Table)
    .or_where(Expr::col(Glyph::Id).lt(1))
    .or_where(Expr::col(Glyph::Id).gt(10))
    .to_owned();

assert_eq!(
    query.to_string(MysqlQueryBuilder),
    r#"DELETE FROM `glyph` WHERE `id` < 1 OR `id` > 10"#
);
assert_eq!(
    query.to_string(PostgresQueryBuilder),
    r#"DELETE FROM "glyph" WHERE "id" < 1 OR "id" > 10"#
);
assert_eq!(
    query.to_string(SqliteQueryBuilder),
    r#"DELETE FROM `glyph` WHERE `id` < 1 OR `id` > 10"#
);

Implementations

impl DeleteStatement[src]

pub fn new() -> Self[src]

Construct a new DeleteStatement

pub fn from_table<T>(&mut self, tbl_ref: T) -> &mut Self where
    T: IntoTableRef
[src]

Specify which table to delete from.

Examples

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

let query = Query::delete()
    .from_table(Glyph::Table)
    .and_where(Expr::col(Glyph::Id).eq(1))
    .to_owned();

assert_eq!(
    query.to_string(MysqlQueryBuilder),
    r#"DELETE FROM `glyph` WHERE `id` = 1"#
);
assert_eq!(
    query.to_string(PostgresQueryBuilder),
    r#"DELETE FROM "glyph" WHERE "id" = 1"#
);
assert_eq!(
    query.to_string(SqliteQueryBuilder),
    r#"DELETE FROM `glyph` WHERE `id` = 1"#
);

pub fn limit(&mut self, limit: u64) -> &mut Self[src]

Limit number of updated rows.

impl DeleteStatement[src]

pub fn to_string<T: QueryBuilder>(&self, query_builder: T) -> String[src]

pub fn build<T: QueryBuilder>(&self, query_builder: T) -> (String, Values)[src]

pub fn build_any(&self, query_builder: &dyn QueryBuilder) -> (String, Values)[src]

impl DeleteStatement[src]

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

pub fn order_by_tbl<T, C>(
    &mut self,
    table: T,
    col: C,
    order: Order
) -> &mut Self where
    T: IntoIden,
    C: IntoIden
[src]

πŸ‘Ž Deprecated since 0.9.0:

Please use the [OrderedStatement::order_by] with a tuple as [ColumnRef]

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

pub fn order_by_customs<T>(&mut self, cols: Vec<(T, Order)>) -> &mut Self where
    T: ToString
[src]

pub fn order_by_columns<T>(&mut self, cols: Vec<(T, Order)>) -> &mut Self where
    T: IntoColumnRef
[src]

pub fn order_by_table_columns<T, C>(
    &mut self,
    cols: Vec<(T, C, Order)>
) -> &mut Self where
    T: IntoIden,
    C: IntoIden
[src]

πŸ‘Ž Deprecated since 0.9.0:

Please use the [OrderedStatement::order_by_columns] with a tuple as [ColumnRef]

impl DeleteStatement[src]

pub fn and_where(&mut self, other: SimpleExpr) -> &mut Self[src]

pub fn and_where_option(&mut self, other: Option<SimpleExpr>) -> &mut Self[src]

pub fn or_where(&mut self, other: SimpleExpr) -> &mut Self[src]

πŸ‘Ž Deprecated since 0.12.0:

Please use [ConditionalStatement::cond_where]. Calling or_where after and_where will panic.

pub fn cond_where<C>(&mut self, condition: C) -> &mut Self where
    C: IntoCondition
[src]

Trait Implementations

impl Clone for DeleteStatement[src]

fn clone(&self) -> DeleteStatement[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl ConditionalStatement for DeleteStatement[src]

fn and_or_where(&mut self, condition: LogicalChainOper) -> &mut Self[src]

fn cond_where<C>(&mut self, condition: C) -> &mut Self where
    C: IntoCondition
[src]

Where condition, expressed with any and all. This cannot be mixed with ConditionalStatement::and_where. Calling cond_where after and_where will panic. Calling cond_where multiple times will conjoin them. Read more

fn and_where(&mut self, other: SimpleExpr) -> &mut Self[src]

And where condition. This cannot be mixed with ConditionalStatement::or_where. Calling or_where after and_where will panic. Read more

fn and_where_option(&mut self, other: Option<SimpleExpr>) -> &mut Self[src]

And where condition, short hand for if c.is_some() q.and_where(c).

fn or_where(&mut self, other: SimpleExpr) -> &mut Self[src]

πŸ‘Ž Deprecated since 0.12.0:

Please use [ConditionalStatement::cond_where]. Calling or_where after and_where will panic.

impl Debug for DeleteStatement[src]

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

Formats the value using the given formatter. Read more

impl Default for DeleteStatement[src]

fn default() -> Self[src]

Returns the β€œdefault value” for a type. Read more

impl OrderedStatement for DeleteStatement[src]

fn add_order_by(&mut self, order: OrderExpr) -> &mut Self[src]

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

Order by column. Read more

fn order_by_tbl<T, C>(&mut self, table: T, col: C, order: Order) -> &mut Self where
    T: IntoIden,
    C: IntoIden
[src]

πŸ‘Ž Deprecated since 0.9.0:

Please use the [OrderedStatement::order_by] with a tuple as [ColumnRef]

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

Order by SimpleExpr.

fn order_by_customs<T>(&mut self, cols: Vec<(T, Order)>) -> &mut Self where
    T: ToString
[src]

Order by custom string.

fn order_by_columns<T>(&mut self, cols: Vec<(T, Order)>) -> &mut Self where
    T: IntoColumnRef
[src]

Order by vector of columns.

fn order_by_table_columns<T, C>(
    &mut self,
    cols: Vec<(T, C, Order)>
) -> &mut Self where
    T: IntoIden,
    C: IntoIden
[src]

πŸ‘Ž Deprecated since 0.9.0:

Please use the [OrderedStatement::order_by_columns] with a tuple as [ColumnRef]

impl QueryStatementBuilder for DeleteStatement[src]

fn build_collect<T: QueryBuilder>(
    &self,
    query_builder: T,
    collector: &mut dyn FnMut(Value)
) -> String
[src]

Build corresponding SQL statement for certain database backend and collect query parameters

Examples

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

let query = Query::delete()
    .from_table(Glyph::Table)
    .and_where(Expr::col(Glyph::Id).eq(1))
    .to_owned();

assert_eq!(
    query.to_string(MysqlQueryBuilder),
    r#"DELETE FROM `glyph` WHERE `id` = 1"#
);

let mut params = Vec::new();
let mut collector = |v| params.push(v);

assert_eq!(
    query.build_collect(MysqlQueryBuilder, &mut collector),
    r#"DELETE FROM `glyph` WHERE `id` = ?"#
);
assert_eq!(
    params,
    vec![
        Value::Int(1),
    ]
);

fn build_collect_any(
    &self,
    query_builder: &dyn QueryBuilder,
    collector: &mut dyn FnMut(Value)
) -> String
[src]

Build corresponding SQL statement for certain database backend and collect query parameters

fn to_string<T: QueryBuilder>(&self, query_builder: T) -> String[src]

Build corresponding SQL statement for certain database backend and return SQL string Read more

fn build<T: QueryBuilder>(&self, query_builder: T) -> (String, Values)[src]

Build corresponding SQL statement for certain database backend and collect query parameters into a vector Read more

fn build_any(&self, query_builder: &dyn QueryBuilder) -> (String, Values)[src]

Build corresponding SQL statement for certain database backend and collect query parameters into a vector

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

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

pub fn clone_into(&self, target: &mut T)[src]

πŸ”¬ This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

pub fn vzip(self) -> V