sqlx
sqlx copied to clipboard
UNION not supported?
Hi, not sure if this a bug or expected behaviour or just me misunderstanding how to use UNION, but it would be great if this would work:
This code compiles fine against my DB:
let notes = sqlx::query_as!(
Note,
"
SELECT * FROM note
"
)
.fetch_all(conn)
.await?;
While this one fails
let notes = sqlx::query_as!(
Note,
"
SELECT * FROM note
UNION
SELECT * FROM note
"
)
.fetch_all(conn)
.await?;
With compile error:
mismatched types
expected type `i32`
found enum `std::option::Option<i32>`rustc[E0308](https://doc.rust-lang.org/error-index.html#E0308)
[macros.rs(552, 9): ]()Actual error occurred here
[macros.rs(552, 9): ]()Error originated from macro call here
mismatched types
expected struct `OffsetDateTime`
found enum `std::option::Option<OffsetDateTime>`rustc[E0308](https://doc.rust-lang.org/error-index.html#E0308)
[macros.rs(552, 9): ]()Actual error occurred here
[macros.rs(552, 9): ]()Error originated from macro call here
mismatched types
expected struct `std::string::String`
found enum `std::option::Option<std::string::String>`rustc[E0308](https://doc.rust-lang.org/error-index.html#E0308)
[macros.rs(552, 9): ]()Actual error occurred here
[macros.rs(552, 9): ]()Error originated from macro call here
@felixwatts what database are you using?
Postgres
Duplicate of #1266