cargo fmt

This commit is contained in:
Billy Chan 2021-08-29 22:18:53 +08:00
parent 4d0c5f0b0f
commit 333f199c1a
No known key found for this signature in database
GPG Key ID: A2D690CAC7DF3CC7
3 changed files with 12 additions and 13 deletions

View File

@ -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();

View File

@ -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 })
}

View File

@ -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::Model> =
Customer::find_by_id(customer_id.clone().unwrap())
.one(db)
.await
.expect("could not find customer");
let customer: Option<customer::Model> = Customer::find_by_id(customer_id.clone().unwrap())
.one(db)
.await
.expect("could not find customer");
assert_eq!(customer, None);
}