{{{#!diff
diff --git a/django/core/management/commands/sqlmigrate.py
b/django/core/management/commands/sqlmigrate.py
index 2f6993682f..158bcf722b 100644
--- a/django/core/management/commands/sqlmigrate.py
+++ b/django/core/management/commands/sqlmigrate.py
@@ -1,3 +1,5 @@
+import sqlparse
+
from django.apps import apps
from django.core.management.base import BaseCommand, CommandError
from django.db import DEFAULT_DB_ALIAS, connections
@@ -80,4 +82,4 @@ class Command(BaseCommand):
sql_statements = loader.collect_sql(plan)
if not sql_statements and options["verbosity"] >= 1:
self.stderr.write("No operations found.")
- return "\n".join(sql_statements)
+ return sqlparse.format("\n".join(sql_statements), reindent=True)
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34859>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Comment (by David Sanders):
Personally I'm not sure it's worth formatting… it's kinda nice to have the
current format have 1 line per ddl statement. Additionally in my
experience sqlmigrate's formatting of ddl is lack lustre 🤷♂️
--
Ticket URL: <https://code.djangoproject.com/ticket/34859#comment:1>
* status: new => closed
* resolution: => wontfix
Comment:
Thanks Paolo for your ticket!
I personally think that if we were to do this, it should be via a
dedicated CLI switch, I wouldn't change the default formatting because
there may be tools that parse this output and assume one command per line.
Having said that, I would suggest/like that this feature request is
proposed in the Django forum to reach a wider audience, Trac notifications
are receive by a small subset of people from the community.
Following the triage procedure, I'll close as wontfix pending the
conversation in the forum, happy to re-open later!
--
Ticket URL: <https://code.djangoproject.com/ticket/34859#comment:2>
Comment (by Natalia Bidart):
Replying to [comment:1 David Sanders]:
> Personally I'm not sure it's worth formatting… it's kinda nice to have
the current format have 1 line per ddl statement. Additionally in my
experience sqlmigrate's formatting of ddl is lack lustre 🤷♂️
Did you mean that `sqlmigrate`'s formatting is subpar, or that
`sqlparse`'s is?
--
Ticket URL: <https://code.djangoproject.com/ticket/34859#comment:3>
Comment (by David Sanders):
> Did you mean that sqlmigrate's formatting is subpar, or that sqlparse's
is?
oops! I meant sqlparse :)
--
Ticket URL: <https://code.djangoproject.com/ticket/34859#comment:4>