Skip to main content

UpdateByKey

Struct UpdateByKey 

Source
pub struct UpdateByKey {
    pub table: TableId,
    pub keys: Vec<Value>,
    pub assignments: Assignments,
    pub filter: Option<Expr>,
    pub condition: Option<Expr>,
    pub returning: Option<Vec<ColumnId>>,
}
Expand description

Updates one or more records identified by primary key.

Used by key-value drivers. SQL drivers receive an equivalent UPDATE statement via QuerySql instead. Supports conditional updates and optionally returns the updated records.

§Examples

use toasty_core::driver::operation::{UpdateByKey, Operation};

let op = UpdateByKey {
    table: table_id,
    keys: vec![key_value],
    assignments: assignments,
    filter: None,
    condition: None,
    returning: None,
};
let operation: Operation = op.into();

Fields§

§table: TableId

The table to update.

§keys: Vec<Value>

Primary key values identifying the records to update.

§assignments: Assignments

Column assignments describing how to modify the records.

§filter: Option<Expr>

Optional filter expression. When set, only records whose key is in keys and that match this filter are updated.

§condition: Option<Expr>

Optional precondition that must hold for the update to be applied. Unlike filter, a failed condition typically causes an error rather than silently skipping the row.

§returning: Option<Vec<ColumnId>>

The columns to return for each updated row.

None returns the affected-row count. Some(columns) returns one record per updated row containing exactly these columns, in this order, in the ExecResponse. The engine builds this list explicitly, so the driver never has to infer which columns to return from the assignments.

Trait Implementations§

Source§

impl Clone for UpdateByKey

Source§

fn clone(&self) -> UpdateByKey

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for UpdateByKey

Source§

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

Formats the value using the given formatter. Read more
Source§

impl From<UpdateByKey> for Operation

Source§

fn from(value: UpdateByKey) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more