Skip to content

Commit 014e922

Browse files
replace % with mod() SQL function to avoid invalid double-percentage signs
1 parent f1f239c commit 014e922

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

django_celery_beat/schedulers.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from django.conf import settings
1717
from django.core.exceptions import ObjectDoesNotExist
1818
from django.db import close_old_connections, transaction
19-
from django.db.models import Case, F, IntegerField, Q, When
19+
from django.db.models import Case, ExpressionWrapper, F, Func, IntegerField, Q, When
2020
from django.db.models.functions import Cast
2121
from django.db.utils import DatabaseError, InterfaceError
2222
from kombu.utils.encoding import safe_repr, safe_str
@@ -331,11 +331,16 @@ def _get_crontab_exclude_query(self):
331331
*[
332332
When(
333333
timezone=timezone_name,
334-
then=(
335-
F('hour_int')
336-
+ self._get_timezone_offset(timezone_name)
337-
+ 24
338-
) % 24
334+
then=ExpressionWrapper(
335+
Func(
336+
F('hour_int')
337+
+ self._get_timezone_offset(timezone_name)
338+
+ 24,
339+
24,
340+
function='MOD'
341+
),
342+
output_field=IntegerField(),
343+
),
339344
)
340345
for timezone_name in self._get_unique_timezone_names()
341346
],

0 commit comments

Comments
 (0)