#17158: django.db.backends.BaseDatabaseOperations.last_executed_query can raise 
an
exception
-------------------------------------+-------------------------------------
     Reporter:  a.gerchenov@…        |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  1.2
  (models, ORM)                      |               Resolution:
     Severity:  Normal               |             Triage Stage:  Accepted
     Keywords:                       |      Needs documentation:  0
    Has patch:  0                    |  Patch needs improvement:  0
  Needs tests:  0                    |                    UI/UX:  0
Easy pickings:  0                    |
-------------------------------------+-------------------------------------
Changes (by aaugustin):

 * needs_better_patch:   => 0
 * stage:  Unreviewed => Accepted
 * needs_docs:   => 0
 * needs_tests:   => 0


Comment:

 Since r16081, there is a better implementation of `last_executed_query`
 for MySQL (and Oracle), so the problem is solved as far as MySQL is
 concerned.

 It still exists for SQLite, and although we came to the conclusion that we
 couldn't build a reliable `last_executed_query` for SQLite in #14091, it
 shouldn't raise an exception.

 I see three possible solutions:

 - 1) give up on interpolation entirely, and return a string like "SQL =
 ..., PARAMS = ...".
 - 2) catch errors in the interpolation and return only smart_unicode(sql)
 - 3) mangle the SQL to replace some % by %% before interpolation.

 I'm in favor of 1 because it will avoid returning subtly invalid SQL when
 the database backend in SQLite. It's backwards incompatible, but
 `last_executed_query` never returned something usable under SQLite.
 Returning obviously incomplete SQL is less likely to confuse newcomers.

 I'm against 3 because it's overengineering, and I'm not convinced it's
 possible to get it right for all cases anyway.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/17158#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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to