Skip to main content

GuardedUpdate

Struct GuardedUpdate 

Source
pub struct GuardedUpdate<E: EntityTrait> { /* private fields */ }

Implementations§

Source§

impl<E: EntityTrait> GuardedUpdate<E>

Source

pub fn new(entity: E) -> Self

Start a new builder targeting entity.

Source

pub fn filter<F: IntoCondition>(self, f: F) -> Self

Add a filter expression. Multiple .filter(...) calls AND-combine.

Source

pub fn set_expr(self, col: E::Column, expr: SimpleExpr) -> Self

Set a column to a value-derived expression.

Source

pub fn set_value(self, col: E::Column, value: Value) -> Self

Set a column to a literal value.

Source

pub async fn exec_one<C: ConnectionTrait>( self, conn: &C, ) -> Result<(), GuardedError>

Execute the conditional UPDATE; succeed iff exactly one row matched.

Returns Err(GuardedError::NoRowsAffected) on 0 rows (predicate failure — the race-free “capacity exhausted” signal). Returns Err(GuardedError::TooManyRows { affected }) on >1 rows (filter is not unique-key-equivalent — index/uniqueness bug).

Note on TooManyRows: this variant is preserved for documentation and future-proofing. sea-orm’s UpdateMany::exec returns rows_affected unconditionally on success, so a filter matching >1 rows will mutate every matched row before this post-processor surfaces the error. The variant is the right way to shout when a supposed unique-key-equivalent filter turns out not to be — see Pitfall 4 in 152-RESEARCH.md.

Source

pub async fn exec_at_most_one<C: ConnectionTrait>( self, conn: &C, ) -> Result<bool, GuardedError>

Execute the conditional UPDATE; tolerate 0 rows as a normal outcome.

Returns Ok(true) on 1 row, Ok(false) on 0 rows. >1 rows still returns Err(GuardedError::TooManyRows) — the uniqueness contract is the same.

Auto Trait Implementations§

§

impl<E> !RefUnwindSafe for GuardedUpdate<E>

§

impl<E> !UnwindSafe for GuardedUpdate<E>

§

impl<E> Freeze for GuardedUpdate<E>
where E: Freeze,

§

impl<E> Send for GuardedUpdate<E>

§

impl<E> Sync for GuardedUpdate<E>

§

impl<E> Unpin for GuardedUpdate<E>
where E: Unpin, <E as EntityTrait>::Column: Unpin,

§

impl<E> UnsafeUnpin for GuardedUpdate<E>
where E: UnsafeUnpin,

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

Source§

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

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

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

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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