Struct sea_query::query::UpdateStatement [−][src]
pub struct UpdateStatement { /* fields omitted */ }
Expand description
Update existing rows in the table
Examples
use sea_query::{*, tests_cfg::*}; let query = Query::update() .table(Glyph::Table) .values(vec![ (Glyph::Aspect, 1.23.into()), (Glyph::Image, "123".into()), ]) .and_where(Expr::col(Glyph::Id).eq(1)) .to_owned(); assert_eq!( query.to_string(MysqlQueryBuilder), r#"UPDATE `glyph` SET `aspect` = 1.23, `image` = '123' WHERE `id` = 1"# ); assert_eq!( query.to_string(PostgresQueryBuilder), r#"UPDATE "glyph" SET "aspect" = 1.23, "image" = '123' WHERE "id" = 1"# ); assert_eq!( query.to_string(SqliteQueryBuilder), r#"UPDATE `glyph` SET `aspect` = 1.23, `image` = '123' WHERE `id` = 1"# );
Implementations
impl UpdateStatement
[src]
impl UpdateStatement
[src]impl UpdateStatement
[src]
impl UpdateStatement
[src]pub fn order_by<T>(&mut self, col: T, order: Order) -> &mut Self where
T: IntoColumnRef,
[src]
T: IntoColumnRef,
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 [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]
T: ToString,
pub fn order_by_columns<T>(&mut self, cols: Vec<(T, Order)>) -> &mut Self where
T: IntoColumnRef,
[src]
T: IntoColumnRef,
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 [OrderedStatement::order_by_columns
] with a tuple as [ColumnRef
]
impl UpdateStatement
[src]
impl UpdateStatement
[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]
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]
C: IntoCondition,
impl UpdateStatement
[src]
impl UpdateStatement
[src]pub fn new() -> Self
[src]
pub fn new() -> Self
[src]Construct a new UpdateStatement
pub fn table<T>(&mut self, tbl_ref: T) -> &mut Self where
T: IntoTableRef,
[src]
pub fn table<T>(&mut self, tbl_ref: T) -> &mut Self where
T: IntoTableRef,
[src]pub fn into_table<T>(&mut self, table: T) -> &mut Self where
T: IntoTableRef,
[src]
T: IntoTableRef,
Please use the UpdateStatement::table function instead
pub fn value_expr<T>(&mut self, col: T, exp: SimpleExpr) -> &mut Self where
T: IntoIden,
[src]
pub fn value_expr<T>(&mut self, col: T, exp: SimpleExpr) -> &mut Self where
T: IntoIden,
[src]Update column value by SimpleExpr
.
Examples
use sea_query::{*, tests_cfg::*}; let query = Query::update() .table(Glyph::Table) .value_expr(Glyph::Aspect, Expr::cust("60 * 24 * 24")) .values(vec![ (Glyph::Image, "24B0E11951B03B07F8300FD003983F03F0780060".into()), ]) .and_where(Expr::col(Glyph::Id).eq(1)) .to_owned(); assert_eq!( query.to_string(MysqlQueryBuilder), r#"UPDATE `glyph` SET `aspect` = 60 * 24 * 24, `image` = '24B0E11951B03B07F8300FD003983F03F0780060' WHERE `id` = 1"# ); assert_eq!( query.to_string(PostgresQueryBuilder), r#"UPDATE "glyph" SET "aspect" = 60 * 24 * 24, "image" = '24B0E11951B03B07F8300FD003983F03F0780060' WHERE "id" = 1"# ); assert_eq!( query.to_string(SqliteQueryBuilder), r#"UPDATE `glyph` SET `aspect` = 60 * 24 * 24, `image` = '24B0E11951B03B07F8300FD003983F03F0780060' WHERE `id` = 1"# );
pub fn json(&mut self, values: JsonValue) -> &mut Self
[src]
This is supported on crate feature with-json
only.
pub fn json(&mut self, values: JsonValue) -> &mut Self
[src]with-json
only.Update column values by JsonValue
. A convenience method if you have multiple column-value pairs to set at once.
Examples
use sea_query::{*, tests_cfg::*}; let query = Query::update() .table(Glyph::Table) .json(json!({ "aspect": 2.1345, "image": "235m", })) .and_where(Expr::col(Glyph::Id).eq(1)) .to_owned(); assert_eq!( query.to_string(MysqlQueryBuilder), r#"UPDATE `glyph` SET `aspect` = 2.1345, `image` = '235m' WHERE `id` = 1"# ); assert_eq!( query.to_string(PostgresQueryBuilder), r#"UPDATE "glyph" SET "aspect" = 2.1345, "image" = '235m' WHERE "id" = 1"# ); assert_eq!( query.to_string(SqliteQueryBuilder), r#"UPDATE `glyph` SET `aspect` = 2.1345, `image` = '235m' WHERE `id` = 1"# );
pub fn values<T, I>(&mut self, values: I) -> &mut Self where
T: IntoIden,
I: IntoIterator<Item = (T, Value)>,
[src]
pub fn values<T, I>(&mut self, values: I) -> &mut Self where
T: IntoIden,
I: IntoIterator<Item = (T, Value)>,
[src]Update column values.. A convenience method if you have multiple column-value pairs to set at once.
Examples
use sea_query::{*, tests_cfg::*}; let query = Query::update() .table(Glyph::Table) .values(vec![ (Glyph::Aspect, 2.1345.into()), (Glyph::Image, "235m".into()), ]) .and_where(Expr::col(Glyph::Id).eq(1)) .to_owned(); assert_eq!( query.to_string(MysqlQueryBuilder), r#"UPDATE `glyph` SET `aspect` = 2.1345, `image` = '235m' WHERE `id` = 1"# ); assert_eq!( query.to_string(PostgresQueryBuilder), r#"UPDATE "glyph" SET "aspect" = 2.1345, "image" = '235m' WHERE "id" = 1"# ); assert_eq!( query.to_string(SqliteQueryBuilder), r#"UPDATE `glyph` SET `aspect` = 2.1345, `image` = '235m' WHERE `id` = 1"# );
pub fn value<T>(&mut self, col: T, value: Value) -> &mut Self where
T: IntoIden,
[src]
pub fn value<T>(&mut self, col: T, value: Value) -> &mut Self where
T: IntoIden,
[src]Update column values.
Examples
use sea_query::{*, tests_cfg::*}; let query = Query::update() .table(Glyph::Table) .value(Glyph::Aspect, 2.1345.into()) .value(Glyph::Image, "235m".into()) .and_where(Expr::col(Glyph::Id).eq(1)) .to_owned(); assert_eq!( query.to_string(MysqlQueryBuilder), r#"UPDATE `glyph` SET `aspect` = 2.1345, `image` = '235m' WHERE `id` = 1"# ); assert_eq!( query.to_string(PostgresQueryBuilder), r#"UPDATE "glyph" SET "aspect" = 2.1345, "image" = '235m' WHERE "id" = 1"# ); assert_eq!( query.to_string(SqliteQueryBuilder), r#"UPDATE `glyph` SET `aspect` = 2.1345, `image` = '235m' WHERE `id` = 1"# );
Trait Implementations
impl Clone for UpdateStatement
[src]
impl Clone for UpdateStatement
[src]fn clone(&self) -> UpdateStatement
[src]
fn clone(&self) -> UpdateStatement
[src]Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]Performs copy-assignment from source
. Read more
impl ConditionalStatement for UpdateStatement
[src]
impl ConditionalStatement for UpdateStatement
[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]
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]
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]
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]
fn or_where(&mut self, other: SimpleExpr) -> &mut Self
[src]Please use [ConditionalStatement::cond_where
]. Calling or_where
after and_where
will panic.
impl Debug for UpdateStatement
[src]
impl Debug for UpdateStatement
[src]impl Default for UpdateStatement
[src]
impl Default for UpdateStatement
[src]impl OrderedStatement for UpdateStatement
[src]
impl OrderedStatement for UpdateStatement
[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]
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]
fn order_by_tbl<T, C>(&mut self, table: T, col: C, order: Order) -> &mut Self where
T: IntoIden,
C: IntoIden,
[src]Please use the [OrderedStatement::order_by
] with a tuple as [ColumnRef
]
fn order_by_expr(&mut self, expr: SimpleExpr, order: Order) -> &mut Self
[src]
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]
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]
fn order_by_columns<T>(&mut self, cols: Vec<(T, Order)>) -> &mut Self where
T: IntoColumnRef,
[src]Order by vector of columns.
impl QueryStatementBuilder for UpdateStatement
[src]
impl QueryStatementBuilder for UpdateStatement
[src]fn build_collect<T: QueryBuilder>(
&self,
query_builder: T,
collector: &mut dyn FnMut(Value)
) -> String
[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::update() .table(Glyph::Table) .values(vec![ (Glyph::Aspect, 2.1345.into()), (Glyph::Image, "235m".into()), ]) .and_where(Expr::col(Glyph::Id).eq(1)) .to_owned(); assert_eq!( query.to_string(MysqlQueryBuilder), r#"UPDATE `glyph` SET `aspect` = 2.1345, `image` = '235m' WHERE `id` = 1"# ); let mut params = Vec::new(); let mut collector = |v| params.push(v); assert_eq!( query.build_collect(MysqlQueryBuilder, &mut collector), r#"UPDATE `glyph` SET `aspect` = ?, `image` = ? WHERE `id` = ?"# ); assert_eq!( params, vec![ Value::Double(2.1345), Value::String(Box::new(String::from("235m"))), Value::Int(1), ] );
fn build_collect_any(
&self,
query_builder: &dyn QueryBuilder,
collector: &mut dyn FnMut(Value)
) -> String
[src]
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]
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
Auto Trait Implementations
impl !RefUnwindSafe for UpdateStatement
impl !Send for UpdateStatement
impl !Sync for UpdateStatement
impl Unpin for UpdateStatement
impl !UnwindSafe for UpdateStatement
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> Same<T> for T
impl<T> Same<T> for T
type Output = T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
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]
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<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,