-
Notifications
You must be signed in to change notification settings - Fork 467
replace % with mod() SQL function to avoid invalid double-percentage … #923
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
base: main
Are you sure you want to change the base?
Conversation
3455663
to
014e922
Compare
for more information, see https://pre-commit.ci
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.
Pull Request Overview
This PR fixes a SQL generation issue where Django was producing invalid double-percentage (%%
) operators in MySQL queries. The fix replaces the Python modulo operator (%
) with Django's Func
class using the SQL MOD()
function to ensure proper SQL syntax.
Key Changes
- Replaces Python modulo operator with Django's
Func
class usingMOD
function - Wraps the expression in
ExpressionWrapper
with proper output field type - Adds necessary imports for
ExpressionWrapper
andFunc
from django.db.models import (Case, ExpressionWrapper, F, Func, IntegerField, | ||
Q, When) |
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.
[nitpick] The import statement is split across multiple lines in an inconsistent format. Consider keeping all imports on the same line or using a more consistent multi-line format with proper indentation.
from django.db.models import (Case, ExpressionWrapper, F, Func, IntegerField, | |
Q, When) | |
from django.db.models import ( | |
Case, ExpressionWrapper, F, Func, IntegerField, Q, When | |
) |
Copilot uses AI. Check for mistakes.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #923 +/- ##
=======================================
Coverage 88.19% 88.19%
=======================================
Files 32 32
Lines 1008 1008
Branches 105 105
=======================================
Hits 889 889
Misses 101 101
Partials 18 18 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
is nit pissible to modify the relevant tests as well?
can you give me some guidance there:
|
this should be the primary file https://github.com/celery/django-celery-beat/blob/main/t/unit/test_schedulers.py and for tests there are docker and tox for running tests locally |
fixes #922
invalid SQL before:
new SQL: