Open
Description
When selecting rows using WHERE IN (SUBQUERY) sqlx erroneously(?) tries to return the rows with every field as nullable:
struct Todo {
id: i64,
description: String,
done: bool,
}
sqlx::query_as!(
Todo,
"SELECT * FROM todos WHERE id IN (SELECT todo_id FROM todo_things)"
)
➜ todos-example git:(master) cargo check
Checking sqlx-example-postgres-connected-todos v0.1.0 (/home/github/todos-example)
error[E0308]: mismatched types
--> src/main.rs:19:17
|
19 | let todos = sqlx::query_as!(
| _________________^
20 | | Todo,
21 | | "SELECT * FROM todos WHERE id IN (SELECT todo_id FROM todo_things)"
22 | | )
| |_____^ expected `i64`, found enum `Option`
|
= note: expected type `i64`
found enum `Option<i64>`
= note: this error originates in the macro `$crate::sqlx_macros::expand_query` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> src/main.rs:19:17
|
19 | let todos = sqlx::query_as!(
| _________________^
20 | | Todo,
21 | | "SELECT * FROM todos WHERE id IN (SELECT todo_id FROM todo_things)"
22 | | )
| |_____^ expected struct `String`, found enum `Option`
|
= note: expected struct `String`
found enum `Option<String>`
= note: this error originates in the macro `$crate::sqlx_macros::expand_query` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> src/main.rs:19:17
|
19 | let todos = sqlx::query_as!(
| _________________^
20 | | Todo,
21 | | "SELECT * FROM todos WHERE id IN (SELECT todo_id FROM todo_things)"
22 | | )
| |_____^ expected `bool`, found enum `Option`
|
= note: expected type `bool`
found enum `Option<bool>`
= note: this error originates in the macro `$crate::sqlx_macros::expand_query` (in Nightly builds, run with -Z macro-backtrace for more info)
For more information about this error, try `rustc --explain E0308`.
error: could not compile `sqlx-example-postgres-connected-todos` due to 3 previous errors
Example repo can be found from https://github.com/regularfellow/todos-example if helpful.