Opened 2 years ago
Last modified 2 years ago
#34659 closed Uncategorized
mysql backend creates queries using CONVERT_TZ even when this is not supported — at Version 1
| Reported by: | Klaas van Schelven | Owned by: | nobody |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | 4.2 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description (last modified by )
To test whether a mysql server has the zoninfo database loaded (feature name: has_zoneinfo_database), the [following code](https://github.com/django/django/blob/1fe0b167af3611cca79e8a8092ee929312193c6f/django/db/backends/mysql/base.py#L410) 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 [generating sql](https://github.com/django/django/blob/main/django/db/backends/mysql/operations.py#L94), 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