#33602: when use date_hierarchy in admin,  it report a error.   django 3.2.12,
mysql-connector-python8.0.28,  mysql server 8.0.28
-------------------------------------+-------------------------------------
     Reporter:  Eric Pan             |                    Owner:  nobody
         Type:  Bug                  |                   Status:  closed
    Component:  Database layer       |                  Version:  3.2
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  needsinfo
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

 * status:  new => closed
 * resolution:   => needsinfo
 * component:  contrib.admin => Database layer (models, ORM)
 * type:  Uncategorized => Bug


Old description:

> \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.

New description:

 \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.

--

Comment:

 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?

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33602#comment:1>
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/0107017fc6e957ee-6574061b-b6cd-4b6d-a080-a86cdcb81876-000000%40eu-central-1.amazonses.com.

Reply via email to