From 333f199c1a566066fb06e6bc6d1c5b4158101948 Mon Sep 17 00:00:00 2001 From: Billy Chan Date: Sun, 29 Aug 2021 22:18:53 +0800 Subject: [PATCH] cargo fmt --- src/executor/execute.rs | 4 +++- src/executor/insert.rs | 12 +++++------- tests/crud/updates.rs | 9 ++++----- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/executor/execute.rs b/src/executor/execute.rs index f05ee963..46ba2d69 100644 --- a/src/executor/execute.rs +++ b/src/executor/execute.rs @@ -23,7 +23,9 @@ impl ExecResult { #[cfg(feature = "sqlx-mysql")] ExecResultHolder::SqlxMySql(result) => result.last_insert_id(), #[cfg(feature = "sqlx-postgres")] - ExecResultHolder::SqlxPostgres(_) => panic!("Should not retrieve last_insert_id this way"), + ExecResultHolder::SqlxPostgres(_) => { + panic!("Should not retrieve last_insert_id this way") + } #[cfg(feature = "sqlx-sqlite")] ExecResultHolder::SqlxSqlite(result) => { let last_insert_rowid = result.last_insert_rowid(); diff --git a/src/executor/insert.rs b/src/executor/insert.rs index 7e5e24aa..e806fe62 100644 --- a/src/executor/insert.rs +++ b/src/executor/insert.rs @@ -89,15 +89,13 @@ where let res = conn.query_one(statement).await?.unwrap(); res.try_get("", "last_insert_id").unwrap_or_default() } - _ => { - db.execute(statement).await? + _ => db + .execute(statement) + .await? .last_insert_id() .to_string() .parse() - .unwrap_or_default() - }, + .unwrap_or_default(), }; - Ok(InsertResult { - last_insert_id, - }) + Ok(InsertResult { last_insert_id }) } diff --git a/tests/crud/updates.rs b/tests/crud/updates.rs index df797ed3..172c9c21 100644 --- a/tests/crud/updates.rs +++ b/tests/crud/updates.rs @@ -130,11 +130,10 @@ pub async fn test_update_deleted_customer(db: &DbConn) { assert_eq!(Customer::find().count(db).await.unwrap(), init_n_customers); - let customer: Option = - Customer::find_by_id(customer_id.clone().unwrap()) - .one(db) - .await - .expect("could not find customer"); + let customer: Option = Customer::find_by_id(customer_id.clone().unwrap()) + .one(db) + .await + .expect("could not find customer"); assert_eq!(customer, None); }