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
Construct a new DeleteStatement
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 order_by_tbl<T, C>(
&mut self,
table: T,
col: C,
order: Order
) -> &mut Self where
T: IntoIden,
C: IntoIden,
Please use the [OrderedStatement::order_by
] with a tuple as [ColumnRef
]
pub fn order_by_columns<T>(&mut self, cols: Vec<(T, Order)>) -> &mut Self where
T: IntoColumnRef,
pub fn order_by_table_columns<T, C>(
&mut self,
cols: Vec<(T, C, Order)>
) -> &mut Self where
T: IntoIden,
C: IntoIden,
Please use the [OrderedStatement::order_by_columns
] with a tuple as [ColumnRef
]
Please use [ConditionalStatement::cond_where
]. Calling or_where
after and_where
will panic.
Trait Implementations
Where condition, expressed with any
and all
.
Calling cond_where
multiple times will conjoin them.
Calling or_where
after cond_where
will panic. Read more
And where condition. This cannot be mixed with ConditionalStatement::or_where
.
Calling or_where
after and_where
will panic. Read more
Optional and where, short hand for if c.is_some() q.and_where(c)
. Read more
Please use [ConditionalStatement::cond_where
]. Calling or_where
after and_where
will panic.
Or where condition. This cannot be mixed with ConditionalStatement::and_where
.
Calling or_where
after and_where
will panic. Read more
Order by column. Read more
Please use the [OrderedStatement::order_by
] with a tuple as [ColumnRef
]
Order by SimpleExpr
.
Order by custom string.
Order by vector of columns.
fn build_collect<T: QueryBuilder>(
&self,
query_builder: T,
collector: &mut dyn FnMut(Value)
) -> String
fn build_collect<T: QueryBuilder>(
&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),
]
);
fn build_collect_any(
&self,
query_builder: &dyn QueryBuilder,
collector: &mut dyn FnMut(Value)
) -> String
fn build_collect_any(
&self,
query_builder: &dyn QueryBuilder,
collector: &mut dyn FnMut(Value)
) -> String
Build corresponding SQL statement for certain database backend and collect query parameters
Build corresponding SQL statement for certain database backend and return SQL string Read more
Build corresponding SQL statement for certain database backend and collect query parameters into a vector Read more
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
Mutably borrows from an owned value. Read more
type Output = T
type Output = T
Should always be Self