﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
35448	test --debug-sql SQL formatting is applied to more than the query	Tim Graham	Tim Graham	"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)""."	Cleanup/optimization	closed	Testing framework	dev	Normal	fixed			Ready for checkin	1	0	0	0	0	0
