the trait bound bool: std::convert::From<std::option::Option<bool>> is not satisfied
I have found these related issues/pull requests
None
Description
let rows = sqlx::query_as!(
DBImportTorrent,
r#"
SELECT
id,
upload_factor,
download_factor,
seeders,
leechers,
times_completed,
CASE
WHEN deleted_at IS NOT NULL THEN TRUE
ELSE FALSE
END AS is_deleted
FROM torrents
"#
)
#[derive(Debug)]
pub struct DBImportTorrent {
pub id: i32,
pub upload_factor: f64,
pub download_factor: f64,
pub seeders: i64,
pub leechers: i64,
pub times_completed: i32,
pub is_deleted: bool,
}
Throws this error: the trait bound bool: std::convert::From<std::option::Option<bool>> is not satisfied
Reproduction steps
Run the code above
SQLx version
0.8
Enabled SQLx features
"runtime-tokio", "tls-native-tls", "postgres", "chrono", "ipnetwork"
Database server and version
Postgres
Operating system
Asahi linux
Rust version
1.89.0
You can override the macro's, see https://docs.rs/sqlx/latest/sqlx/macro.query.html#type-overrides-output-columns.
Which boils down to changing the as is_deleted part of the query to as "is_deleted!".
that works indeed, but will it keep checking for type safety then ?
No, the is_deleted field's type is overridden, so you're opting out of typechecking. The other fields however are still checked.
No, the
is_deletedfield's type is overridden, so you're opting out of typechecking.
Okay, so there is actually a bug in the situation I pointed out ? It's not blocking, but still a bug