Struct sea_query::query::DeleteStatement [−][src]
pub struct DeleteStatement { /* fields omitted */ }
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]
T: IntoTableRef,
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 and_where(&mut self, other: SimpleExpr) -> &mut Self
[src]
And where condition.
Examples
use sea_query::{*, tests_cfg::*}; let query = Query::delete() .from_table(Glyph::Table) .and_where(Expr::col(Glyph::Id).gt(1)) .and_where(Expr::col(Glyph::Id).lt(10)) .to_owned(); assert_eq!( query.to_string(MysqlQueryBuilder), r#"DELETE FROM `glyph` WHERE (`id` > 1) AND (`id` < 10)"# ); assert_eq!( query.to_string(PostgresQueryBuilder), r#"DELETE FROM "glyph" WHERE ("id" > 1) AND ("id" < 10)"# ); assert_eq!( query.to_string(SqliteQueryBuilder), r#"DELETE FROM `glyph` WHERE (`id` > 1) AND (`id` < 10)"# );
pub fn or_where(&mut self, other: SimpleExpr) -> &mut Self
[src]
And where condition.
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)"# );
pub fn order_by<T>(&mut self, col: T, order: Order) -> &mut Self where
T: IntoColumnRef,
[src]
T: IntoColumnRef,
Order by column.
pub fn order_by_tbl<T, C>(
&mut self,
table: T,
col: C,
order: Order
) -> &mut Self where
T: IntoIden,
C: IntoIden,
[src]
&mut self,
table: T,
col: C,
order: Order
) -> &mut Self where
T: IntoIden,
C: IntoIden,
Please use the [DeleteStatement::order_by
] with a tuple as [ColumnRef
]
Order by column with table name prefix.
pub fn order_by_expr(&mut self, expr: SimpleExpr, order: Order) -> &mut Self
[src]
Order by SimpleExpr
.
pub fn order_by_customs<T, I>(&mut self, cols: I) -> &mut Self where
T: ToString,
I: IntoIterator<Item = (T, Order)>,
[src]
T: ToString,
I: IntoIterator<Item = (T, Order)>,
Order by custom string.
pub fn order_by_columns<T, I>(&mut self, cols: I) -> &mut Self where
T: IntoColumnRef,
I: IntoIterator<Item = (T, Order)>,
[src]
T: IntoColumnRef,
I: IntoIterator<Item = (T, Order)>,
Order by columns.
pub fn order_by_table_columns<T, C>(
&mut self,
cols: Vec<(T, C, Order)>
) -> &mut Self where
T: IntoIden,
C: IntoIden,
[src]
&mut self,
cols: Vec<(T, C, Order)>
) -> &mut Self where
T: IntoIden,
C: IntoIden,
Please use the [DeleteStatement::order_by_columns
] with a tuple as [ColumnRef
]
pub fn limit(&mut self, limit: u64) -> &mut Self
[src]
Limit number of updated rows.
pub fn build_collect<T: QueryBuilder>(
&self,
query_builder: T,
collector: &mut dyn FnMut(Value)
) -> String
[src]
&self,
query_builder: T,
collector: &mut dyn FnMut(Value)
) -> String
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), ] );
pub fn build_collect_any(
&self,
query_builder: &dyn QueryBuilder,
collector: &mut dyn FnMut(Value)
) -> String
[src]
&self,
query_builder: &dyn QueryBuilder,
collector: &mut dyn FnMut(Value)
) -> String
Build corresponding SQL statement for certain database backend and collect query parameters
pub 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
Examples
use sea_query::{*, tests_cfg::*}; let (query, params) = Query::delete() .from_table(Glyph::Table) .and_where(Expr::col(Glyph::Id).eq(1)) .build(MysqlQueryBuilder); assert_eq!( query, r#"DELETE FROM `glyph` WHERE `id` = ?"# ); assert_eq!( params, Values(vec![ Value::Int(1), ]) );
pub 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
pub fn to_string<T: QueryBuilder>(&self, query_builder: T) -> String
[src]
Build corresponding SQL statement for certain database backend and return SQL string
Examples
use sea_query::{*, tests_cfg::*}; let query = Query::delete() .from_table(Glyph::Table) .and_where(Expr::col(Glyph::Id).eq(1)) .to_string(MysqlQueryBuilder); assert_eq!( query, r#"DELETE FROM `glyph` WHERE `id` = 1"# );
Trait Implementations
impl Clone for DeleteStatement
[src]
fn clone(&self) -> DeleteStatement
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for DeleteStatement
[src]
impl Default for DeleteStatement
[src]
Auto Trait Implementations
impl !RefUnwindSafe for DeleteStatement
impl !Send for DeleteStatement
impl !Sync for DeleteStatement
impl Unpin for DeleteStatement
impl !UnwindSafe for DeleteStatement
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
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]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
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]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,