Ticket #3480: 3480.diff

File 3480.diff, 1.6 KB (added by jpd <jd@…>, 17 years ago)

Patch to check for GenericRel type at deletion (already done at creation)

  • django/core/management/sql.py

     
    116116    "Returns a list of the DROP TABLE SQL statements for the given app."
    117117    from django.db import connection, models, get_introspection_module
    118118    from django.db.backends.util import truncate_name
     119    from django.contrib.contenttypes import generic
    119120    introspection = get_introspection_module()
    120121
    121122    # This should work even if a connection isn't available
     
    179180    for model in app_models:
    180181        opts = model._meta
    181182        for f in opts.many_to_many:
    182             if cursor and table_name_converter(f.m2m_db_table()) in table_names:
    183                 output.append("%s %s;" % (style.SQL_KEYWORD('DROP TABLE'),
    184                     style.SQL_TABLE(qn(f.m2m_db_table()))))
    185                 ds = connection.ops.drop_sequence_sql("%s_%s" % (model._meta.db_table, f.column))
    186                 if ds:
    187                     output.append(ds)
     183            if not isinstance(f.rel, generic.GenericRel):
     184                if cursor and table_name_converter(f.m2m_db_table()) in table_names:
     185                    output.append("%s %s;" % (style.SQL_KEYWORD('DROP TABLE'),
     186                        style.SQL_TABLE(qn(f.m2m_db_table()))))
     187                    ds = connection.ops.drop_sequence_sql("%s_%s" % (model._meta.db_table, f.column))
     188                    if ds:
     189                        output.append(ds)
    188190
    189191    app_label = app_models[0]._meta.app_label
    190192
Back to Top