Fix clippy warnings (#1437)
This commit is contained in:
parent
4e3a45c2f7
commit
b21abf617f
1
.github/workflows/rust.yml
vendored
1
.github/workflows/rust.yml
vendored
@ -107,6 +107,7 @@ jobs:
|
||||
toolchain: stable
|
||||
components: clippy
|
||||
- run: cargo clippy --all -- -D warnings
|
||||
- run: cargo clippy --all --features runtime-async-std-native-tls,sqlx-all -- -D warnings
|
||||
- run: cargo clippy --manifest-path sea-orm-cli/Cargo.toml -- -D warnings
|
||||
- run: cargo clippy --manifest-path sea-orm-migration/Cargo.toml -- -D warnings
|
||||
- run: cargo clippy --manifest-path sea-orm-rocket/Cargo.toml -- -D warnings
|
||||
|
@ -224,7 +224,8 @@ impl SqlxMySqlPoolConnection {
|
||||
|
||||
/// Explicitly close the MySQL connection
|
||||
pub async fn close(self) -> Result<(), DbErr> {
|
||||
Ok(self.pool.close().await)
|
||||
self.pool.close().await;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ impl SqlxPostgresConnector {
|
||||
let set_search_path_sql = options
|
||||
.schema_search_path
|
||||
.as_ref()
|
||||
.map(|schema| format!("SET search_path = '{}'", schema));
|
||||
.map(|schema| format!("SET search_path = '{schema}'"));
|
||||
let mut pool_options = options.pool_options();
|
||||
if let Some(sql) = set_search_path_sql {
|
||||
pool_options = pool_options.after_connect(move |conn, _| {
|
||||
@ -239,7 +239,8 @@ impl SqlxPostgresPoolConnection {
|
||||
|
||||
/// Explicitly close the Postgres connection
|
||||
pub async fn close(self) -> Result<(), DbErr> {
|
||||
Ok(self.pool.close().await)
|
||||
self.pool.close().await;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -231,7 +231,8 @@ impl SqlxSqlitePoolConnection {
|
||||
|
||||
/// Explicitly close the SQLite connection
|
||||
pub async fn close(self) -> Result<(), DbErr> {
|
||||
Ok(self.pool.close().await)
|
||||
self.pool.close().await;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -108,7 +108,7 @@ impl fmt::Debug for QueryResultRow {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
#[cfg(feature = "sqlx-mysql")]
|
||||
Self::SqlxMySql(row) => write!(f, "{:?}", row),
|
||||
Self::SqlxMySql(row) => write!(f, "{row:?}"),
|
||||
#[cfg(feature = "sqlx-postgres")]
|
||||
Self::SqlxPostgres(_) => write!(f, "QueryResultRow::SqlxPostgres cannot be inspected"),
|
||||
#[cfg(feature = "sqlx-sqlite")]
|
||||
|
@ -35,7 +35,7 @@ async fn setup_schema(db: &DbConn) -> Result<(), DbErr> {
|
||||
|
||||
let builder = db.get_database_backend();
|
||||
let result = db.execute(builder.build(&stmt)).await?;
|
||||
println!("Create table cake: {:?}", result);
|
||||
println!("Create table cake: {result:?}");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@ -50,7 +50,7 @@ async fn crud_cake(db: &DbConn) -> Result<(), DbErr> {
|
||||
let mut apple = apple.save(db).await?;
|
||||
|
||||
println!();
|
||||
println!("Inserted: {:?}", apple);
|
||||
println!("Inserted: {apple:?}");
|
||||
|
||||
assert_eq!(
|
||||
apple,
|
||||
@ -65,12 +65,12 @@ async fn crud_cake(db: &DbConn) -> Result<(), DbErr> {
|
||||
let apple = apple.save(db).await?;
|
||||
|
||||
println!();
|
||||
println!("Updated: {:?}", apple);
|
||||
println!("Updated: {apple:?}");
|
||||
|
||||
let count = cake::Entity::find().count(db).await?;
|
||||
|
||||
println!();
|
||||
println!("Count: {:?}", count);
|
||||
println!("Count: {count:?}");
|
||||
assert_eq!(count, 1);
|
||||
|
||||
let apple = cake::Entity::find_by_id(1).one(db).await?;
|
||||
@ -88,7 +88,7 @@ async fn crud_cake(db: &DbConn) -> Result<(), DbErr> {
|
||||
let result = apple.delete(db).await?;
|
||||
|
||||
println!();
|
||||
println!("Deleted: {:?}", result);
|
||||
println!("Deleted: {result:?}");
|
||||
|
||||
let apple = cake::Entity::find_by_id(1).one(db).await?;
|
||||
|
||||
@ -97,7 +97,7 @@ async fn crud_cake(db: &DbConn) -> Result<(), DbErr> {
|
||||
let count = cake::Entity::find().count(db).await?;
|
||||
|
||||
println!();
|
||||
println!("Count: {:?}", count);
|
||||
println!("Count: {count:?}");
|
||||
assert_eq!(count, 0);
|
||||
|
||||
Ok(())
|
||||
|
@ -31,7 +31,7 @@ pub async fn test_cake_error_sqlx(db: &DbConn) {
|
||||
.expect_err("inserting should fail due to duplicate primary key");
|
||||
|
||||
#[cfg(any(feature = "sqlx-mysql", feature = "sqlx-sqlite"))]
|
||||
match error {
|
||||
match &error {
|
||||
DbErr::Exec(RuntimeErr::SqlxError(error)) => match error {
|
||||
Error::Database(e) => {
|
||||
#[cfg(feature = "sqlx-mysql")]
|
||||
@ -44,7 +44,7 @@ pub async fn test_cake_error_sqlx(db: &DbConn) {
|
||||
_ => panic!("Unexpected Error kind"),
|
||||
}
|
||||
#[cfg(feature = "sqlx-postgres")]
|
||||
match error {
|
||||
match &error {
|
||||
DbErr::Query(RuntimeErr::SqlxError(error)) => match error {
|
||||
Error::Database(e) => {
|
||||
assert_eq!(e.code().unwrap(), "23505");
|
||||
|
@ -208,8 +208,8 @@ async fn loader_load_many() -> Result<(), DbErr> {
|
||||
.await
|
||||
.expect("Should load bakers");
|
||||
|
||||
println!("A: {:?}", bakers);
|
||||
println!("B: {:?}", bakeries);
|
||||
println!("A: {bakers:?}");
|
||||
println!("B: {bakeries:?}");
|
||||
|
||||
assert_eq!(bakeries, [bakery_1, bakery_2]);
|
||||
|
||||
|
@ -253,11 +253,11 @@ pub async fn inner_join() {
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(results.len(), 2);
|
||||
assert!((&results)
|
||||
assert!(results
|
||||
.iter()
|
||||
.any(|result| result.name == customer_kate.name.clone()
|
||||
&& result.order_total == Some(kate_order_1.total)));
|
||||
assert!((&results)
|
||||
assert!(results
|
||||
.iter()
|
||||
.any(|result| result.name == customer_kate.name.clone()
|
||||
&& result.order_total == Some(kate_order_2.total)));
|
||||
@ -499,7 +499,7 @@ pub async fn linked() -> Result<(), DbErr> {
|
||||
"home": "0395555555",
|
||||
"address": "12 Test St, Testville, Vic, Australia"
|
||||
})),
|
||||
bakery_id: Set(Some(seaside_bakery_res.last_insert_id as i32)),
|
||||
bakery_id: Set(Some(seaside_bakery_res.last_insert_id)),
|
||||
..Default::default()
|
||||
};
|
||||
let baker_bob_res = Baker::insert(baker_bob).exec(&ctx.db).await?;
|
||||
@ -508,13 +508,13 @@ pub async fn linked() -> Result<(), DbErr> {
|
||||
price: Set(dec!(10.25)),
|
||||
gluten_free: Set(false),
|
||||
serial: Set(Uuid::new_v4()),
|
||||
bakery_id: Set(Some(seaside_bakery_res.last_insert_id as i32)),
|
||||
bakery_id: Set(Some(seaside_bakery_res.last_insert_id)),
|
||||
..Default::default()
|
||||
};
|
||||
let mud_cake_res = Cake::insert(mud_cake).exec(&ctx.db).await?;
|
||||
let bob_cakes_bakers = cakes_bakers::ActiveModel {
|
||||
cake_id: Set(mud_cake_res.last_insert_id as i32),
|
||||
baker_id: Set(baker_bob_res.last_insert_id as i32),
|
||||
cake_id: Set(mud_cake_res.last_insert_id),
|
||||
baker_id: Set(baker_bob_res.last_insert_id),
|
||||
};
|
||||
CakesBakers::insert(bob_cakes_bakers).exec(&ctx.db).await?;
|
||||
|
||||
@ -524,7 +524,7 @@ pub async fn linked() -> Result<(), DbErr> {
|
||||
contact_details: Set(serde_json::json!({
|
||||
"mobile": "+85212345678",
|
||||
})),
|
||||
bakery_id: Set(Some(seaside_bakery_res.last_insert_id as i32)),
|
||||
bakery_id: Set(Some(seaside_bakery_res.last_insert_id)),
|
||||
..Default::default()
|
||||
};
|
||||
let baker_bobby_res = Baker::insert(baker_bobby).exec(&ctx.db).await?;
|
||||
@ -533,13 +533,13 @@ pub async fn linked() -> Result<(), DbErr> {
|
||||
price: Set(dec!(20.5)),
|
||||
gluten_free: Set(false),
|
||||
serial: Set(Uuid::new_v4()),
|
||||
bakery_id: Set(Some(seaside_bakery_res.last_insert_id as i32)),
|
||||
bakery_id: Set(Some(seaside_bakery_res.last_insert_id)),
|
||||
..Default::default()
|
||||
};
|
||||
let cheese_cake_res = Cake::insert(cheese_cake).exec(&ctx.db).await?;
|
||||
let bobby_cakes_bakers = cakes_bakers::ActiveModel {
|
||||
cake_id: Set(cheese_cake_res.last_insert_id as i32),
|
||||
baker_id: Set(baker_bobby_res.last_insert_id as i32),
|
||||
cake_id: Set(cheese_cake_res.last_insert_id),
|
||||
baker_id: Set(baker_bobby_res.last_insert_id),
|
||||
};
|
||||
CakesBakers::insert(bobby_cakes_bakers)
|
||||
.exec(&ctx.db)
|
||||
@ -549,13 +549,13 @@ pub async fn linked() -> Result<(), DbErr> {
|
||||
price: Set(dec!(30.15)),
|
||||
gluten_free: Set(false),
|
||||
serial: Set(Uuid::new_v4()),
|
||||
bakery_id: Set(Some(seaside_bakery_res.last_insert_id as i32)),
|
||||
bakery_id: Set(Some(seaside_bakery_res.last_insert_id)),
|
||||
..Default::default()
|
||||
};
|
||||
let chocolate_cake_res = Cake::insert(chocolate_cake).exec(&ctx.db).await?;
|
||||
let bobby_cakes_bakers = cakes_bakers::ActiveModel {
|
||||
cake_id: Set(chocolate_cake_res.last_insert_id as i32),
|
||||
baker_id: Set(baker_bobby_res.last_insert_id as i32),
|
||||
cake_id: Set(chocolate_cake_res.last_insert_id),
|
||||
baker_id: Set(baker_bobby_res.last_insert_id),
|
||||
};
|
||||
CakesBakers::insert(bobby_cakes_bakers)
|
||||
.exec(&ctx.db)
|
||||
@ -569,16 +569,16 @@ pub async fn linked() -> Result<(), DbErr> {
|
||||
};
|
||||
let customer_kate_res = Customer::insert(customer_kate).exec(&ctx.db).await?;
|
||||
let kate_order_1 = order::ActiveModel {
|
||||
bakery_id: Set(seaside_bakery_res.last_insert_id as i32),
|
||||
customer_id: Set(customer_kate_res.last_insert_id as i32),
|
||||
bakery_id: Set(seaside_bakery_res.last_insert_id),
|
||||
customer_id: Set(customer_kate_res.last_insert_id),
|
||||
total: Set(dec!(15.10)),
|
||||
placed_at: Set(Utc::now().naive_utc()),
|
||||
..Default::default()
|
||||
};
|
||||
let kate_order_1_res = Order::insert(kate_order_1).exec(&ctx.db).await?;
|
||||
lineitem::ActiveModel {
|
||||
cake_id: Set(cheese_cake_res.last_insert_id as i32),
|
||||
order_id: Set(kate_order_1_res.last_insert_id as i32),
|
||||
cake_id: Set(cheese_cake_res.last_insert_id),
|
||||
order_id: Set(kate_order_1_res.last_insert_id),
|
||||
price: Set(dec!(7.55)),
|
||||
quantity: Set(2),
|
||||
..Default::default()
|
||||
@ -586,16 +586,16 @@ pub async fn linked() -> Result<(), DbErr> {
|
||||
.save(&ctx.db)
|
||||
.await?;
|
||||
let kate_order_2 = order::ActiveModel {
|
||||
bakery_id: Set(seaside_bakery_res.last_insert_id as i32),
|
||||
customer_id: Set(customer_kate_res.last_insert_id as i32),
|
||||
bakery_id: Set(seaside_bakery_res.last_insert_id),
|
||||
customer_id: Set(customer_kate_res.last_insert_id),
|
||||
total: Set(dec!(29.7)),
|
||||
placed_at: Set(Utc::now().naive_utc()),
|
||||
..Default::default()
|
||||
};
|
||||
let kate_order_2_res = Order::insert(kate_order_2).exec(&ctx.db).await?;
|
||||
lineitem::ActiveModel {
|
||||
cake_id: Set(chocolate_cake_res.last_insert_id as i32),
|
||||
order_id: Set(kate_order_2_res.last_insert_id as i32),
|
||||
cake_id: Set(chocolate_cake_res.last_insert_id),
|
||||
order_id: Set(kate_order_2_res.last_insert_id),
|
||||
price: Set(dec!(9.9)),
|
||||
quantity: Set(3),
|
||||
..Default::default()
|
||||
@ -611,16 +611,16 @@ pub async fn linked() -> Result<(), DbErr> {
|
||||
};
|
||||
let customer_kara_res = Customer::insert(customer_kara).exec(&ctx.db).await?;
|
||||
let kara_order_1 = order::ActiveModel {
|
||||
bakery_id: Set(seaside_bakery_res.last_insert_id as i32),
|
||||
customer_id: Set(customer_kara_res.last_insert_id as i32),
|
||||
bakery_id: Set(seaside_bakery_res.last_insert_id),
|
||||
customer_id: Set(customer_kara_res.last_insert_id),
|
||||
total: Set(dec!(15.10)),
|
||||
placed_at: Set(Utc::now().naive_utc()),
|
||||
..Default::default()
|
||||
};
|
||||
let kara_order_1_res = Order::insert(kara_order_1).exec(&ctx.db).await?;
|
||||
lineitem::ActiveModel {
|
||||
cake_id: Set(mud_cake_res.last_insert_id as i32),
|
||||
order_id: Set(kara_order_1_res.last_insert_id as i32),
|
||||
cake_id: Set(mud_cake_res.last_insert_id),
|
||||
order_id: Set(kara_order_1_res.last_insert_id),
|
||||
price: Set(dec!(7.55)),
|
||||
quantity: Set(2),
|
||||
..Default::default()
|
||||
@ -628,16 +628,16 @@ pub async fn linked() -> Result<(), DbErr> {
|
||||
.save(&ctx.db)
|
||||
.await?;
|
||||
let kara_order_2 = order::ActiveModel {
|
||||
bakery_id: Set(seaside_bakery_res.last_insert_id as i32),
|
||||
customer_id: Set(customer_kara_res.last_insert_id as i32),
|
||||
bakery_id: Set(seaside_bakery_res.last_insert_id),
|
||||
customer_id: Set(customer_kara_res.last_insert_id),
|
||||
total: Set(dec!(29.7)),
|
||||
placed_at: Set(Utc::now().naive_utc()),
|
||||
..Default::default()
|
||||
};
|
||||
let kara_order_2_res = Order::insert(kara_order_2).exec(&ctx.db).await?;
|
||||
lineitem::ActiveModel {
|
||||
cake_id: Set(cheese_cake_res.last_insert_id as i32),
|
||||
order_id: Set(kara_order_2_res.last_insert_id as i32),
|
||||
cake_id: Set(cheese_cake_res.last_insert_id),
|
||||
order_id: Set(kara_order_2_res.last_insert_id),
|
||||
price: Set(dec!(9.9)),
|
||||
quantity: Set(3),
|
||||
..Default::default()
|
||||
|
@ -74,7 +74,7 @@ async fn seed_data(db: &DatabaseConnection) {
|
||||
.expect("could not insert cake");
|
||||
|
||||
let cake_baker = cakes_bakers::ActiveModel {
|
||||
cake_id: Set(cake_insert_res.last_insert_id as i32),
|
||||
cake_id: Set(cake_insert_res.last_insert_id),
|
||||
baker_id: Set(baker_1.id.clone().unwrap()),
|
||||
};
|
||||
|
||||
@ -108,7 +108,7 @@ async fn seed_data(db: &DatabaseConnection) {
|
||||
.expect("could not insert order");
|
||||
|
||||
let _lineitem = lineitem::ActiveModel {
|
||||
cake_id: Set(cake_insert_res.last_insert_id as i32),
|
||||
cake_id: Set(cake_insert_res.last_insert_id),
|
||||
price: Set(dec!(10.00)),
|
||||
quantity: Set(12),
|
||||
order_id: Set(kate_order_1.id.clone().unwrap()),
|
||||
@ -119,7 +119,7 @@ async fn seed_data(db: &DatabaseConnection) {
|
||||
.expect("could not insert order");
|
||||
|
||||
let _lineitem2 = lineitem::ActiveModel {
|
||||
cake_id: Set(cake_insert_res.last_insert_id as i32),
|
||||
cake_id: Set(cake_insert_res.last_insert_id),
|
||||
price: Set(dec!(50.00)),
|
||||
quantity: Set(2),
|
||||
order_id: Set(kate_order_1.id.clone().unwrap()),
|
||||
@ -210,7 +210,7 @@ async fn create_cake(db: &DatabaseConnection, baker: baker::Model) -> Option<cak
|
||||
.expect("could not insert cake");
|
||||
|
||||
let cake_baker = cakes_bakers::ActiveModel {
|
||||
cake_id: Set(cake_insert_res.last_insert_id as i32),
|
||||
cake_id: Set(cake_insert_res.last_insert_id),
|
||||
baker_id: Set(baker.id),
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user