#34859: Format SQL code prodcued by sqlmigrate
-------------------------------------+-------------------------------------
               Reporter:  Paolo      |          Owner:  nobody
  Melchiorre                         |
                   Type:  New        |         Status:  new
  feature                            |
              Component:             |        Version:  dev
  Migrations                         |       Keywords:  sql, sqlmigrate,
               Severity:  Normal     |  migrations
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 I propose to use `sqlparse`, which is already a Django dependency, to
 format the SQL code generated by the `sqlmigrate` command.


 {{{#!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.

-- 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018ab74c442d-28275bf0-085d-43d5-a703-20ded9c7deeb-000000%40eu-central-1.amazonses.com.

Reply via email to