Skip to content

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions django_celery_beat/schedulers.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
from django.conf import settings
from django.core.exceptions import ObjectDoesNotExist
from django.db import close_old_connections, transaction
from django.db.models import Case, F, IntegerField, Q, When
from django.db.models import (Case, ExpressionWrapper, F, Func, IntegerField,
Q, When)
Comment on lines +19 to +20
Copy link
Preview

Copilot AI Jul 29, 2025

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.

Suggested change
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.

from django.db.models.functions import Cast
from django.db.utils import DatabaseError, InterfaceError
from kombu.utils.encoding import safe_repr, safe_str
Expand Down Expand Up @@ -331,11 +332,16 @@ def _get_crontab_exclude_query(self):
*[
When(
timezone=timezone_name,
then=(
F('hour_int')
+ self._get_timezone_offset(timezone_name)
+ 24
) % 24
then=ExpressionWrapper(
Func(
F('hour_int')
+ self._get_timezone_offset(timezone_name)
+ 24,
24,
function='MOD'
),
output_field=IntegerField(),
),
)
for timezone_name in self._get_unique_timezone_names()
],
Expand Down