pub enum ConflictTarget {
PrimaryKey,
Columns(&'static [&'static str]),
}Expand description
Conflict target for an upsert. Defaults to the model’s primary key
(matching the previous PK-only behavior). Columns lets callers
upsert on an arbitrary unique tuple — most commonly a natural key
that’s distinct from the PK (e.g. (owner_id, provider) on a
per-owner-and-provider settings row, or (pairing_id, slot) on a
per-slot envelope).
The named columns MUST correspond to a UNIQUE constraint or
UNIQUE index on the target table — the database engine enforces
this and will surface a clear error if not. The upsert builder
additionally requires the input to carry a value for every column
in the target tuple, so the conflict probe (SELECT … FOR UPDATE)
has something to filter on.
Composite-constraint-by-name (ON CONFLICT ON CONSTRAINT my_unique_idx_v2) is not yet exposed; pass the matching column
tuple via Self::Columns instead.
Variants§
PrimaryKey
The model’s @id primary key. Default.
Columns(&'static [&'static str])
A caller-supplied tuple of columns forming a unique key on the target table.
Implementations§
Source§impl ConflictTarget
impl ConflictTarget
Sourcepub const fn columns(cols: &'static [&'static str]) -> ConflictTarget
pub const fn columns(cols: &'static [&'static str]) -> ConflictTarget
Sugar for ConflictTarget::Columns(&[...]).
Trait Implementations§
Source§impl Clone for ConflictTarget
impl Clone for ConflictTarget
Source§fn clone(&self) -> ConflictTarget
fn clone(&self) -> ConflictTarget
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ConflictTarget
impl Debug for ConflictTarget
Source§impl Default for ConflictTarget
impl Default for ConflictTarget
Source§fn default() -> ConflictTarget
fn default() -> ConflictTarget
Source§impl PartialEq for ConflictTarget
impl PartialEq for ConflictTarget
Source§fn eq(&self, other: &ConflictTarget) -> bool
fn eq(&self, other: &ConflictTarget) -> bool
self and other values to be equal, and is used by ==.impl Copy for ConflictTarget
impl Eq for ConflictTarget
impl StructuralPartialEq for ConflictTarget
Auto Trait Implementations§
impl Freeze for ConflictTarget
impl RefUnwindSafe for ConflictTarget
impl Send for ConflictTarget
impl Sync for ConflictTarget
impl Unpin for ConflictTarget
impl UnsafeUnpin for ConflictTarget
impl UnwindSafe for ConflictTarget
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more