Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
billy1624 committed Aug 29, 2021
1 parent 4d0c5f0 commit cd31f3d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
4 changes: 3 additions & 1 deletion src/executor/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
12 changes: 5 additions & 7 deletions src/executor/insert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
}
9 changes: 4 additions & 5 deletions tests/crud/updates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit cd31f3d

Please sign in to comment.