Enum TryInsertResult
pub enum TryInsertResult<T> {
Empty,
Conflicted,
Inserted(T),
}Expand description
The result of executing a crate::TryInsert.
This enum represents no‑op inserts (e.g. conflict DO NOTHING) without treating
them as errors.
Variants§
Empty
There was nothing to insert, so no SQL was executed.
This typically happens when creating a crate::TryInsert from an empty iterator or None.
Conflicted
The statement was executed, but SeaORM could not get the inserted row / insert id.
This is commonly caused by ON CONFLICT ... DO NOTHING (Postgres / SQLite) or the MySQL
polyfill (ON DUPLICATE KEY UPDATE pk = pk).
Note that this variant maps from DbErr::RecordNotInserted, so it can also represent other
situations where the backend/driver reports no inserted row (e.g. an empty RETURNING
result set or a “no-op” update in MySQL where last_insert_id is reported as 0). In rare
cases, this can be a false negative where a row was inserted but the backend did not report
it.
Inserted(T)
Successfully inserted
Implementations§
§impl<A> TryInsertResult<InsertResult<A>>where
A: ActiveModelTrait,
impl<A> TryInsertResult<InsertResult<A>>where
A: ActiveModelTrait,
pub fn last_insert_id(
self,
) -> Result<Option<<<<A as ActiveModelTrait>::Entity as EntityTrait>::PrimaryKey as PrimaryKeyTrait>::ValueType>, DbErr>
pub fn last_insert_id( self, ) -> Result<Option<<<<A as ActiveModelTrait>::Entity as EntityTrait>::PrimaryKey as PrimaryKeyTrait>::ValueType>, DbErr>
Extract the last inserted id.
TryInsertResult::Empty=>Ok(None)TryInsertResult::Inserted=>Ok(Some(last_insert_id))TryInsertResult::Conflicted=>Err(DbErr::RecordNotInserted)
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for TryInsertResult<T>where
T: Freeze,
impl<T> RefUnwindSafe for TryInsertResult<T>where
T: RefUnwindSafe,
impl<T> Send for TryInsertResult<T>where
T: Send,
impl<T> Sync for TryInsertResult<T>where
T: Sync,
impl<T> Unpin for TryInsertResult<T>where
T: Unpin,
impl<T> UnwindSafe for TryInsertResult<T>where
T: UnwindSafe,
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> 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