#35448: test --debug-sql SQL formatting is applied to more than the query
---------------------------------------------+------------------------
Reporter: Tim Graham | Owner: nobody
Type: Bug | Status: new
Component: Testing framework | Version: dev
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
---------------------------------------------+------------------------
Since #34111 (3283120cca5d5eba5c3619612d0de5ad49dcf054), the output of
`manage.py test --debug-sql` is
[
https://github.com/django/django/blob/a09082a9bec18f8e3ee8c10d473013ec67ffe93b/django/test/runner.py#L100
formatted with sqlparse]. Because this
[
https://github.com/django/django/blob/ceaf1e2848583ba832cc74715da38c802b6b0671/django/db/backends/utils.py#L152
log message] contains more than SQL (including a prefix with the query's
duration as well as a suffix that includes the query parameters and
database alias) there are some problems with the output.
For example:
{{{
(0.000) SELECT "basic_article"."id", "basic_article"."headline",
"basic_article"."pub_date" FROM "basic_article" WHERE "basic_article"."id"
= 1 LIMIT 21; args=(1,); alias=default
(0.000) SELECT "basic_article"."id", "basic_article"."headline",
"basic_article"."pub_date" FROM "basic_article" WHERE "basic_article"."id"
= 1 LIMIT 21; args=(1,); alias=default
}}}
becomes:
{{{
(0.000)
SELECT "basic_article"."id",
"basic_article"."headline",
"basic_article"."pub_date"
FROM "basic_article"
WHERE "basic_article"."id" = 1
LIMIT 21;
args=(1,);
ALIAS=DEFAULT (0.000)
SELECT "basic_article"."id",
"basic_article"."headline",
"basic_article"."pub_date"
FROM "basic_article"
WHERE "basic_article"."id" = 1
LIMIT 21;
args=(1,);
ALIAS=DEFAULT
}}}
"alias=default" is unexpectedly capitalized since these are SQL reserved
words. There is also the addition of a newline after the duration but not
at the end of the query such that the output from one query runs into the
other: "ALIAS=DEFAULT (0.000)".
--
Ticket URL: <
https://code.djangoproject.com/ticket/35448>
Django <
https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.