#36152: Annotation with `%` in alias fails at db level on Postgres and MySQL
-------------------------------------+-------------------------------------
     Reporter:  Jacob Walls          |                    Owner:  (none)
         Type:                       |                   Status:  new
  Cleanup/optimization               |
    Component:  Database layer       |                  Version:  5.1
  (models, ORM)                      |
     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
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

 * summary:  Annotation with `%` in alias fails at db level on postgres =>
     Annotation with `%` in alias fails at db level on Postgres and MySQL

Comment:

 > Do we need to worry about a deprecation path for non-postgres backends?

 I assume we would need a path yes, it's also crashing on MySQL though so
 not only a problem on Postgres

 {{{#!python
 Traceback (most recent call last):
   File "/usr/local/lib/python3.12/site-packages/MySQLdb/cursors.py", line
 200, in _mogrify
     query = query % args
             ~~~~~~^~~~~~
 TypeError: not enough arguments for format string

 During handling of the above exception, another exception occurred:

 Traceback (most recent call last):
   File "/django/source/django/db/backends/utils.py", line 105, in _execute
     return self.cursor.execute(sql, params)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "/django/source/django/db/backends/mysql/base.py", line 76, in
 execute
     return self.cursor.execute(query, args)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "/usr/local/lib/python3.12/site-packages/MySQLdb/cursors.py", line
 176, in execute
     mogrified_query = self._mogrify(query, args)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "/usr/local/lib/python3.12/site-packages/MySQLdb/cursors.py", line
 202, in _mogrify
     raise ProgrammingError(str(m))
 MySQLdb.ProgrammingError: not enough arguments for format string
 }}}

 The specialized logic for Oracle originated from
 2249bd275cbae6b73716bf36f5f36def1bb4222e which was likely to support
 introspecting legacy tables columns containing `%` signs. Tat means we
 can't realistically deprecate the `quote_name` path entirely. I haven't
 looked into why things work on SQLite.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36152#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 visit 
https://groups.google.com/d/msgid/django-updates/01070194ae04f911-32906f4f-55b7-49bb-9950-a203b032e78b-000000%40eu-central-1.amazonses.com.

Reply via email to