Ticket #9717: 9717.flush_command.diff

File 9717.flush_command.diff, 2.0 KB (added by Julien Phalip, 16 years ago)

Patch, but without regression tests yet...

  • django/django/core/management/commands/flush.py

     
    2727            except ImportError:
    2828                pass
    2929
    30         sql_list = sql_flush(self.style, only_django=True)
     30        sql_list = sql_flush(self.style, only_django=True, only_existing_django=True)
    3131
    3232        if interactive:
    3333            confirm = raw_input("""You have requested a flush of the database.
  • django/django/core/management/sql.py

     
    116116    "Returns a list of the DROP TABLE SQL, then the CREATE TABLE SQL, for the given module."
    117117    return sql_delete(app, style) + sql_all(app, style)
    118118
    119 def sql_flush(style, only_django=False):
     119def sql_flush(style, only_django=False, only_existing_django=False):
    120120    """
    121121    Returns a list of the SQL statements used to flush the database.
    122122   
    123     If only_django is True, then only table names that have associated Django
     123    * If only_django is True, then only table names that have associated Django
    124124    models and are in INSTALLED_APPS will be included.
     125    * only_existing_django is only considered if only_django is True. If
     126    only_existing_django is True, then only table names which *actually exist*
     127    in database will be included.
    125128    """
    126129    from django.db import connection
    127130    if only_django:
    128         tables = connection.introspection.django_table_names()
     131        tables = connection.introspection.django_table_names(only_existing=only_existing_django)
    129132    else:
    130133        tables = connection.introspection.table_names()
    131134    statements = connection.ops.sql_flush(style, tables, connection.introspection.sequence_list())
Back to Top