Skip to content

Commit

Permalink
Address clippy warnings for Rust stable 1.84 (#1168)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaplanelad authored Jan 10, 2025
1 parent abe016e commit 8d2632d
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,7 @@ async fn has_id_column(
let result = db
.query_one(Statement::from_string(DatabaseBackend::Postgres, query))
.await?;
result.map_or(false, |row| {
row.try_get::<bool>("", "exists").unwrap_or(false)
})
result.is_some_and(|row| row.try_get::<bool>("", "exists").unwrap_or(false))
}
DatabaseBackend::Sqlite => {
let query = format!(
Expand All @@ -325,9 +323,7 @@ async fn has_id_column(
let result = db
.query_one(Statement::from_string(DatabaseBackend::Sqlite, query))
.await?;
result.map_or(false, |row| {
row.try_get::<i32>("", "count").unwrap_or(0) > 0
})
result.is_some_and(|row| row.try_get::<i32>("", "count").unwrap_or(0) > 0)
}
DatabaseBackend::MySql => {
return Err(Error::Message(
Expand Down Expand Up @@ -358,19 +354,17 @@ async fn is_auto_increment(
let result = db
.query_one(Statement::from_string(DatabaseBackend::Postgres, query))
.await?;
result.map_or(false, |row| {
row.try_get::<bool>("", "is_serial").unwrap_or(false)
})
result.is_some_and(|row| row.try_get::<bool>("", "is_serial").unwrap_or(false))
}
DatabaseBackend::Sqlite => {
let query =
format!("SELECT sql FROM sqlite_master WHERE type='table' AND name='{table_name}'");
let result = db
.query_one(Statement::from_string(DatabaseBackend::Sqlite, query))
.await?;
result.map_or(false, |row| {
result.is_some_and(|row| {
row.try_get::<String>("", "sql")
.map_or(false, |sql| sql.to_lowercase().contains("autoincrement"))
.is_ok_and(|sql| sql.to_lowercase().contains("autoincrement"))
})
}
DatabaseBackend::MySql => {
Expand Down

0 comments on commit 8d2632d

Please sign in to comment.