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

Query OR syntax #134

Closed
Jaymon opened this issue Jun 25, 2021 · 0 comments
Closed

Query OR syntax #134

Jaymon opened this issue Jun 25, 2021 · 0 comments

Comments

@Jaymon
Copy link
Owner

Jaymon commented Jun 25, 2021

Would something like this work:

Orm.query.eq_foo("<VAL>").or_start().in_bar([1, 2]).eq_bar(None).or_stop().eq_che("<VAL2>")

Would result in a query like:

WHERE
  foo = '<VAL>
AND
  (bar IN (1, 2) OR bar is NULL)
AND
  che = '<VAL2>'

Or, maybe it could be even more clever and just infer:

Orm.query.eq_foo("<VAL>").in_bar([1, 2]).or().eq_bar(None).eq_che("<VAL2>")

I think that could work, the idea would be that the .or() just combines the last set WHERE value and wraps it in parens with whatever comes next. If you do another .or() then it would just append that on again, so you can have whole chains of (... OR ... OR ...) statement fragments. I actually think that might work.

This would also give a viable path for #123 without having to implement anything that looks at every value passed into the in_* method

@Jaymon Jaymon closed this as completed in f22b7ee Mar 24, 2023
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

1 participant