#33602 closed Bug (invalid)
when use date_hierarchy in admin, it report a error. django 3.2.12, mysql-connector-python8.0.28, mysql server 8.0.28 — at Version 1
Reported by: | Eric Pan | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 3.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 )
\site-packages\django\db\backends\mysql\operations.py line 58
def date_trunc_sql(self, lookup_type, field_name, tzname=None): field_name = self._convert_field_to_tz(field_name, tzname) fields = { 'year': '%%Y-01-01', 'month': '%%Y-%%m-01', } # Use double percents to escape.
the problem is here.
'year': '%%Y-01-01', 'month': '%%Y-%%m-01',
this will generate the SQL.
SELECT DISTINCT CAST(DATE_FORMAT([table name], '%%Y-01-01') AS DATE) AS `datefield
the format ''%%Y-01-01''
is not right for mysql.
Change History (1)
comment:1 by , 3 years ago
Component: | contrib.admin → Database layer (models, ORM) |
---|---|
Description: | modified (diff) |
Resolution: | → needsinfo |
Status: | new → closed |
Type: | Uncategorized → Bug |
Note:
See TracTickets
for help on using tickets.
This might be a bug in mysql-connector-python and/or mysql.connector.django which aren't part of Django itself.
What does "the format ... is not right" mean? What's the error?