-
Notifications
You must be signed in to change notification settings - Fork 465
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
Auto-parenthesis for Where() #380
Comments
Ping, maybe @MartyHub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Greets !
Quick suggestion to hear the community's thoughts before opening a PR:
I recently noticed that if one would use
.Where()
and pass it multiple OR clauses, say, without using propersq.Or
,the statement would not be parenthesized:
This is unlike some other query builders, for instance in gorm, the same usage is parenthesized:
Even though sq providers a proper
Or
primitive, the above can still be mistakenly used, which could lead to insidious bugs where the latter part of the OR statement overrides predicates before it.I was wondering if, maybe via an opt-in flag to be backwards compatible, it would make sense to auto-parenthesize statements inside Where() - it could be done for all statements, or only for those that contains "OR" statements.
Let me know the sentiment if this is something we're willing to push, and I'll open a PR.
The text was updated successfully, but these errors were encountered: