#34659: mysql backend creates queries using CONVERT_TZ even when this is not
supported
------------------------------------+--------------------------------------
Reporter: Klaas van Schelven | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 4.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------------+--------------------------------------
Description changed by Klaas van Schelven:
Old description:
> To test whether a mysql server has the zoneinfo database loaded (feature
> name: `has_zoneinfo_database`), the
> [https://github.com/django/django/blob/1fe0b167af3611cca79e8a8092ee929312193c6f/django/db/backends/mysql/base.py#L410
> following code] is run:
>
> {{{
> CONVERT_TZ('2001-01-01 01:00:00', 'UTC', 'UTC') IS NOT NULL
> }}}
>
>
> However, this test is not actually used (i.e. there is no condition on
> the feature being True) when
> [https://github.com/django/django/blob/main/django/db/backends/mysql/operations.py#L94
> generating sql], despite the fact that the generated sql contains
> something that we know will evaluate to `NULL`
>
> This shows up when filtering like so:
>
> {{{
> Foo.objects(some_datetimefield__date="2023-06-16")
> }}}
>
> which evaluates to the empty queryset, despite there being such objects.
> `USE_TZ = True`, obviously
New description:
To test whether a mysql server has the zoneinfo database loaded (feature
name: `has_zoneinfo_database`), the
[https://github.com/django/django/blob/1fe0b167af3611cca79e8a8092ee929312193c6f/django/db/backends/mysql/base.py#L410
following code] is run:
{{{
CONVERT_TZ('2001-01-01 01:00:00', 'UTC', 'UTC') IS NOT NULL
}}}
However, this test is not actually used (i.e. there is no condition on the
feature being True) when
[https://github.com/django/django/blob/main/django/db/backends/mysql/operations.py#L94
generating sql], despite the fact that the generated sql contains
something that we know will evaluate to `NULL`, namely, the very same
`CONVERT_TZ` mentioned in the above.
This shows up when filtering like so:
{{{
Foo.objects(some_datetimefield__date="2023-06-16")
}}}
which evaluates to the empty queryset, despite there being such objects.
`USE_TZ = True`, obviously
--
--
Ticket URL: <https://code.djangoproject.com/ticket/34659#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/01070188c4771314-ca13395a-1fae-4172-b222-0d6eb3d44781-000000%40eu-central-1.amazonses.com.