From 80d3ddc0300921f729b7ac20c7a6832a145b2821 Mon Sep 17 00:00:00 2001 From: Billy Chan Date: Fri, 15 Oct 2021 11:51:05 +0800 Subject: [PATCH] Use backed-up primary key as last insert id before getting it from db driver --- src/executor/insert.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/executor/insert.rs b/src/executor/insert.rs index b4da10c0..9e186ccd 100644 --- a/src/executor/insert.rs +++ b/src/executor/insert.rs @@ -96,10 +96,10 @@ where ValueTypeOf::::try_from_u64(last_insert_id).ok() } }; - let last_insert_id = match last_insert_id_opt { - Some(last_insert_id) => last_insert_id, - None => match primary_key { - Some(value_tuple) => FromValueTuple::from_value_tuple(value_tuple), + let last_insert_id = match primary_key { + Some(value_tuple) => FromValueTuple::from_value_tuple(value_tuple), + None => match last_insert_id_opt { + Some(last_insert_id) => last_insert_id, None => return Err(DbErr::Exec("Fail to unpack last_insert_id".to_owned())), }, };