Refactored get_drop_foreignkey_sql() to DatabaseOperations.drop_foreignkey_sql(). Refs #5106

git-svn-id: http://code.djangoproject.com/svn/django/trunk@5956 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2007-08-19 23:07:34 +00:00
parent 8e84d35d38
commit 23a736dca9
10 changed files with 16 additions and 23 deletions

View File

@ -147,7 +147,7 @@ def sql_delete(app, style):
output.append('%s %s %s %s;' % \ output.append('%s %s %s %s;' % \
(style.SQL_KEYWORD('ALTER TABLE'), (style.SQL_KEYWORD('ALTER TABLE'),
style.SQL_TABLE(backend.quote_name(table)), style.SQL_TABLE(backend.quote_name(table)),
style.SQL_KEYWORD(backend.get_drop_foreignkey_sql()), style.SQL_KEYWORD(connection.ops.drop_foreignkey_sql()),
style.SQL_FIELD(truncate_name(r_name, backend.get_max_name_length())))) style.SQL_FIELD(truncate_name(r_name, backend.get_max_name_length()))))
del references_to_delete[model] del references_to_delete[model]
if model._meta.has_auto_field and hasattr(backend, 'get_drop_sequence'): if model._meta.has_auto_field and hasattr(backend, 'get_drop_sequence'):

View File

@ -85,3 +85,9 @@ class BaseDatabaseOperations(object):
during a CREATE TABLE statement. during a CREATE TABLE statement.
""" """
return '' return ''
def drop_foreignkey_sql(self):
"""
Returns the SQL command that drops a foreign key.
"""
return "DROP CONSTRAINT"

View File

@ -113,9 +113,6 @@ def get_random_function_sql():
def get_fulltext_search_sql(field_name): def get_fulltext_search_sql(field_name):
raise NotImplementedError raise NotImplementedError
def get_drop_foreignkey_sql():
return "DROP CONSTRAINT"
def get_pk_default_value(): def get_pk_default_value():
return "DEFAULT" return "DEFAULT"

View File

@ -47,7 +47,6 @@ get_last_insert_id = complain
get_limit_offset_sql = complain get_limit_offset_sql = complain
get_random_function_sql = complain get_random_function_sql = complain
get_fulltext_search_sql = complain get_fulltext_search_sql = complain
get_drop_foreignkey_sql = complain
get_pk_default_value = complain get_pk_default_value = complain
get_max_name_length = ignore get_max_name_length = ignore
get_start_transaction_sql = complain get_start_transaction_sql = complain

View File

@ -71,6 +71,9 @@ class DatabaseOperations(BaseDatabaseOperations):
sql = "CAST(DATE_FORMAT(%s, '%s') AS DATETIME)" % (field_name, format_str) sql = "CAST(DATE_FORMAT(%s, '%s') AS DATETIME)" % (field_name, format_str)
return sql return sql
def drop_foreignkey_sql(self):
return "DROP FOREIGN KEY"
class DatabaseWrapper(BaseDatabaseWrapper): class DatabaseWrapper(BaseDatabaseWrapper):
ops = DatabaseOperations() ops = DatabaseOperations()
@ -164,9 +167,6 @@ def get_random_function_sql():
def get_fulltext_search_sql(field_name): def get_fulltext_search_sql(field_name):
return 'MATCH (%s) AGAINST (%%s IN BOOLEAN MODE)' % field_name return 'MATCH (%s) AGAINST (%%s IN BOOLEAN MODE)' % field_name
def get_drop_foreignkey_sql():
return "DROP FOREIGN KEY"
def get_pk_default_value(): def get_pk_default_value():
return "DEFAULT" return "DEFAULT"

View File

@ -81,6 +81,9 @@ class DatabaseOperations(BaseDatabaseOperations):
sql = "CAST(DATE_FORMAT(%s, '%s') AS DATETIME)" % (field_name, format_str) sql = "CAST(DATE_FORMAT(%s, '%s') AS DATETIME)" % (field_name, format_str)
return sql return sql
def drop_foreignkey_sql(self):
return "DROP FOREIGN KEY"
class DatabaseWrapper(BaseDatabaseWrapper): class DatabaseWrapper(BaseDatabaseWrapper):
ops = DatabaseOperations() ops = DatabaseOperations()
@ -183,9 +186,6 @@ def get_random_function_sql():
def get_fulltext_search_sql(field_name): def get_fulltext_search_sql(field_name):
return 'MATCH (%s) AGAINST (%%s IN BOOLEAN MODE)' % field_name return 'MATCH (%s) AGAINST (%%s IN BOOLEAN MODE)' % field_name
def get_drop_foreignkey_sql():
return "DROP FOREIGN KEY"
def get_pk_default_value(): def get_pk_default_value():
return "DEFAULT" return "DEFAULT"

View File

@ -189,9 +189,6 @@ def get_random_function_sql():
def get_fulltext_search_sql(field_name): def get_fulltext_search_sql(field_name):
raise NotImplementedError raise NotImplementedError
def get_drop_foreignkey_sql():
return "DROP CONSTRAINT"
def get_pk_default_value(): def get_pk_default_value():
return "DEFAULT" return "DEFAULT"

View File

@ -143,9 +143,6 @@ def get_random_function_sql():
def get_fulltext_search_sql(field_name): def get_fulltext_search_sql(field_name):
raise NotImplementedError raise NotImplementedError
def get_drop_foreignkey_sql():
return "DROP CONSTRAINT"
def get_pk_default_value(): def get_pk_default_value():
return "DEFAULT" return "DEFAULT"

View File

@ -97,9 +97,6 @@ def get_random_function_sql():
def get_fulltext_search_sql(field_name): def get_fulltext_search_sql(field_name):
raise NotImplementedError raise NotImplementedError
def get_drop_foreignkey_sql():
return "DROP CONSTRAINT"
def get_pk_default_value(): def get_pk_default_value():
return "DEFAULT" return "DEFAULT"

View File

@ -45,6 +45,9 @@ class DatabaseOperations(BaseDatabaseOperations):
# function django_date_trunc that's registered in connect(). # function django_date_trunc that's registered in connect().
return 'django_date_trunc("%s", %s)' % (lookup_type.lower(), field_name) return 'django_date_trunc("%s", %s)' % (lookup_type.lower(), field_name)
def drop_foreignkey_sql(self):
return ""
class DatabaseWrapper(BaseDatabaseWrapper): class DatabaseWrapper(BaseDatabaseWrapper):
ops = DatabaseOperations() ops = DatabaseOperations()
@ -127,9 +130,6 @@ def get_random_function_sql():
def get_fulltext_search_sql(field_name): def get_fulltext_search_sql(field_name):
raise NotImplementedError raise NotImplementedError
def get_drop_foreignkey_sql():
return ""
def get_pk_default_value(): def get_pk_default_value():
return "NULL" return "NULL"