Skip to content
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

Option is ignored in WhereParam #114

Closed
teenjuna opened this issue Jul 21, 2022 · 2 comments
Closed

Option is ignored in WhereParam #114

teenjuna opened this issue Jul 21, 2022 · 2 comments

Comments

@teenjuna
Copy link

Hi! I have a model with an optional number field (Option<f64>). I needed to query models where the field is not None, but turns out that WhereParam::NumberNot is defined as NumberNot(f64), so I can't use model::number::not(None). I was able to bypass that by using model::number::gt(f64::MIN), but I think it would be harder for fields with non-numeric types.

@teenjuna
Copy link
Author

Another workaround is to use this:

model::WhereParam::Not(vec![model::number::equals(None)]

Which is more semantically correct I guess.

@Brendonovich
Copy link
Owner

Yep, this is how you'd do that query. Note that you can use the not! macro to simplify it to

not![model::number::equals(None)]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants