Skip to content

Commit 1377653

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

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

django_celery_beat/schedulers.py

Lines changed: 9 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,14 @@ 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') + self._get_timezone_offset(timezone_name) + 24,
337+
24,
338+
function='MOD'
339+
),
340+
output_field=IntegerField(),
341+
),
339342
)
340343
for timezone_name in self._get_unique_timezone_names()
341344
],

0 commit comments

Comments
 (0)