pub struct GuardedUpdate<E: EntityTrait> { /* private fields */ }Implementations§
Source§impl<E: EntityTrait> GuardedUpdate<E>
impl<E: EntityTrait> GuardedUpdate<E>
Sourcepub fn filter<F: IntoCondition>(self, f: F) -> Self
pub fn filter<F: IntoCondition>(self, f: F) -> Self
Add a filter expression. Multiple .filter(...) calls AND-combine.
Sourcepub fn set_expr(self, col: E::Column, expr: SimpleExpr) -> Self
pub fn set_expr(self, col: E::Column, expr: SimpleExpr) -> Self
Set a column to a value-derived expression.
Sourcepub async fn exec_one<C: ConnectionTrait>(
self,
conn: &C,
) -> Result<(), GuardedError>
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.
Sourcepub async fn exec_at_most_one<C: ConnectionTrait>(
self,
conn: &C,
) -> Result<bool, GuardedError>
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.