Ticket #1373: fix_drop_foreignkey.diff

File fix_drop_foreignkey.diff, 2.8 KB (added by Geert Vanderkelen <geert@…>, 19 years ago)
  • db/backends/ado_mssql/base.py

     
    114114def get_random_function_sql():
    115115    return "RAND()"
    116116
     117def get_foreignkey_drop(table, name):
     118    return "ALTER TABLE %s DROP CONSTRAINT %s;" % \
     119        (quote_name(table),quote_name(name))
     120
    117121OPERATOR_MAPPING = {
    118122    'exact': '= %s',
    119123    'iexact': 'LIKE %s',
  • db/backends/postgresql/base.py

     
    9191def get_random_function_sql():
    9292    return "RANDOM()"
    9393
     94def get_foreignkey_drop(table, name):
     95    return "ALTER TABLE %s DROP CONSTRAINT %s;" % \
     96        (quote_name(table),quote_name(name))
     97
    9498# Register these custom typecasts, because Django expects dates/times to be
    9599# in Python's native (standard-library) datetime/time format, whereas psycopg
    96100# use mx.DateTime by default.
  • db/backends/sqlite3/base.py

     
    110110def get_random_function_sql():
    111111    return "RANDOM()"
    112112
     113def get_foreignkey_drop(table, name):
     114    return ""
     115
    113116def _sqlite_date_trunc(lookup_type, dt):
    114117    try:
    115118        dt = util.typecast_timestamp(dt)
  • db/backends/mysql/base.py

     
    130130def get_random_function_sql():
    131131    return "RAND()"
    132132
     133def get_foreignkey_drop(table, name):
     134    return "ALTER TABLE %s DROP FOREIGN KEY %s;" % \
     135        (quote_name(table),quote_name(name))
     136
    133137OPERATOR_MAPPING = {
    134138    'exact': '= %s',
    135139    'iexact': 'LIKE %s',
  • core/management.py

     
    252252                    col = f.column
    253253                    r_table = klass._meta.db_table
    254254                    r_col = klass._meta.get_field(f.rel.field_name).column
    255                     output.append('ALTER TABLE %s DROP CONSTRAINT %s;' % \
    256                        (backend.quote_name(table),
    257                         backend.quote_name("%s_referencing_%s_%s" % (col, r_table, r_col))))
     255                    output.append(backend.get_foreignkey_drop(table,
     256                        "%s_referencing_%s_%s" % (col, r_table, r_col)))
    258257                del references_to_delete[klass]
    259258
    260259    # Output DROP TABLE statements for many-to-many tables.
Back to Top