-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
query_as!
does not recognize Option<T>
in some left join
queries
#3408
Comments
This issue seems related but I don't think it's the same. |
sqlx
does not recognize Option<T>
columns when using query_as!
macro with a query with an outer join
and where
outside the joinquery_as!
does not recognize Option<T>
in some left join
queries
I just ran into this, is there a work around? |
Work around is to add |
The thing is, that tells the compiler that the thing you're referencing is not null, which is not what you want on a left join. In the example I made, doing |
I'm also having the same issue and it's driving me nuts. For some reason having a But at least it looks like that you can work around this issue by using It looks like that this is the same issue as #2127 I think. |
Bug Description
If you run a query with a
left join
and awhere
condition outside theleft join
,sqlx
yells at you during runtime (not compile time) with the following error:even if you read the column into an
Option<T>
. However, if you put that condition inside theleft join
, it works fine.Minimal Reproduction
Here's a contrived example with two tables,
employee
anddepartment
:schema.sql
:main.rs
:I believe this is a bug with sqlx because each query returns the expected (and same) result when run in a
psql
shell.PS: I know issue #3336 exists, but I don't think it's quite the same.
Info
rustc --version
: 1.80The text was updated successfully, but these errors were encountered: