#36112: DatabaseOperations.format_debug_sql() crashes when query fails to
execute
on some backends
-----------------------------------+--------------------------------------
Reporter: Jacob Walls | Owner: Tim Graham
Type: Bug | Status: assigned
Component: Testing framework | Version: dev
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------
Changes (by Tim Graham):
* cc: Mariusz Felisiak (added)
* summary: DatabaseOperations.format_debug_sql() crashes on Oracle =>
DatabaseOperations.format_debug_sql() crashes when query fails to
execute on some backends
Comment:
This happens on any database backend where
`DatabaseOperations.last_executed_query()` can return `None` (i.e. the
query failed) For example, I observed the same failure
[https://github.com/django/django/blob/337c641abb36b3c2501b14e1290b800831bb20ad/django/db/backends/postgresql/operations.py#L307-L325
on PostgreSQL].
I think there should either be a guard so that a failed query (`sql=None`)
isn't
[https://github.com/django/django/blob/337c641abb36b3c2501b14e1290b800831bb20ad/django/db/backends/utils.py#L145-L163
logged in the first place] or `DatabaseOperations.last_executed_query()`
subclass implementations could fall back to
[https://github.com/django/django/blob/337c641abb36b3c2501b14e1290b800831bb20ad/django/db/backends/base/operations.py#L265-L287
BaseDatabaseOperations.last_executed_query()] rather than returning
`None`.
It may be useful to see the failing query in the logs, but I'm open to
other opinions about this. The pre-
d8f093908c504ae0dbc39d3f5231f7d7920dde37 behavior is to log `(0.000)
NONE; args=<actual params>; ALIAS=DEFAULT`.
--
Ticket URL: <https://code.djangoproject.com/ticket/36112#comment:6>
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/01070194863fd71d-287ef0c0-ebc3-42a3-8ba8-1d0ca8bdc839-000000%40eu-central-1.amazonses.com.