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ยง
Sourceยงimpl<A> TryInsertResult<InsertResult<A>>where
A: ActiveModelTrait,
impl<A> TryInsertResult<InsertResult<A>>where
A: ActiveModelTrait,
Sourcepub 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