-
Notifications
You must be signed in to change notification settings - Fork 27
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
♻️ Changing == by is_ in sqlalchemy queries #6654
♻️ Changing == by is_ in sqlalchemy queries #6654
Conversation
Quality Gate passedIssues Measures |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #6654 +/- ##
==========================================
- Coverage 87.87% 82.48% -5.40%
==========================================
Files 1563 609 -954
Lines 62881 30889 -31992
Branches 2088 265 -1823
==========================================
- Hits 55258 25478 -29780
+ Misses 7305 5350 -1955
+ Partials 318 61 -257
Continue to review full report in Codecov by Sentry.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wau, cool thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct
What do these changes do?
I've encountered an issue several times where ruff automatically converts expressions like
x == True
tox is True
. This becomes problematic in SQLAlchemy queries when expressions liketable.c.x == True
are involved, as ruff will transform it totable.c.x is True
. While this is syntactically valid, it produces a different SQL querycreates
which will never return anything (wrong!) and
which is the correct filter
I've noticed this bug on multiple occasions and, to prevent it from reoccurring, I've created this PR to update all such occurrences in our repository. This PR also serves as a reminder.
Suggestion
To avoid issues in your SQLAlchemy queries,
table.c.x.is_(True)
instead oftable.c.x == True
.table.c.x.is_not(True)
instead oftable.c.x != True
.False
andNone
(when nullable).Related issue/s
Maintenance.
How to test
None
Dev-ops checklist
None