Skip to main content

ConflictUpdate

Struct ConflictUpdate 

Source
pub struct ConflictUpdate<D, T> { /* private fields */ }
Expand description

The DO UPDATE half of an upsert: everything an UPDATE assigns, plus excluded, plus the WHERE that decides whether the update fires at all. An Assignments converts into one, so a request-shaped patch reaches an upsert as it always did; the reverse doesn’t exist, which is what keeps a list naming the proposed row out of a statement that has none.

It carries D for the reason Predicate does: its WHERE is a condition like any other, and a condition pinned to one dialect must not reach a statement of another. The statement it is passed to says which dialect that is, so a value built inline needs no annotation. One bound to a let and never used does.

Implementations§

Source§

impl<D, T: Table> ConflictUpdate<D, T>

Source

pub fn set_to<C, V, Idxs>(_column: Column<C>, value: V) -> Self
where C: ColumnKey<Table = T> + Writable, V: IntoExpr, V::Sql: AssignsTo<C::Sql>, ConflictScope<T>: Superset<V::Req, Idxs>,

column = <expression>, over the conflicting row and the proposed one. This is Assignments::set_to with the wider scope.

Source

pub fn and_set_to<C, V, Idxs>(self, _column: Column<C>, value: V) -> Self
where C: ColumnKey<Table = T> + Writable, V: IntoExpr, V::Sql: AssignsTo<C::Sql>, ConflictScope<T>: Superset<V::Req, Idxs>,

One more of them.

Source

pub fn filter<C: Condition<D, ConflictScope<T>, Idxs>, Idxs>( self, cond: C, ) -> Self

DO UPDATE SET .. WHERE <condition>: which conflicting rows the update actually touches, over the conflicting row and the proposed one. A row the condition rejects is left as it is and is not counted, so a one-row upsert’s rows_affected() answers “did this write anything” rather than always being 1. It counts the rows a statement wrote, not the branch each took: a multi-row upsert’s count still folds inserts together with updates, and only zero says nothing happened.

A different clause from the one partial_index carries: that one only picks which index the conflict is inferred against.

Source

pub fn filter_all( self, conds: impl IntoIterator<Item = Predicate<D, ConflictScope<T>>>, ) -> Self

AND-folds a runtime-length collection of discharged conditions, the same way Update::filter_all does.

Source

pub fn correlated<S, InnerSel>( &self, source: S, selection: InnerSel, ) -> Select<D, Cons<TableSlot<S::Table, NotNull>, ConflictScope<T>>, InnerSel, ConflictScope<T>>
where S: JoinSource<D>,

A correlated subquery over the rows this action sees. It is the same EXISTS Update::correlated builds, against the conflicting row and the proposed one.

Trait Implementations§

Source§

impl<D, T> From<Assignments<T>> for ConflictUpdate<D, T>

Source§

fn from(sets: Assignments<T>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<D, T> Freeze for ConflictUpdate<D, T>
where PhantomData<fn() -> (D, T)>: Freeze,

§

impl<D, T> RefUnwindSafe for ConflictUpdate<D, T>

§

impl<D, T> Send for ConflictUpdate<D, T>
where PhantomData<fn() -> (D, T)>: Send,

§

impl<D, T> Sync for ConflictUpdate<D, T>
where PhantomData<fn() -> (D, T)>: Sync,

§

impl<D, T> Unpin for ConflictUpdate<D, T>
where PhantomData<fn() -> (D, T)>: Unpin,

§

impl<D, T> UnsafeUnpin for ConflictUpdate<D, T>

§

impl<D, T> UnwindSafe for ConflictUpdate<D, T>

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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<S> Superset<Nil, Nil> for S

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WrapNullable<NotNull> for T