Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

magic-removal: Fixed #1373 -- Factored out database-specific 'DROP CO…

…NSTRAINT' syntax, to get sqlreset/sqlclear working with MySQL. Thanks, njharman

git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2732 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 121c9c96924615022857121225a3019f1fba8365 1 parent c551eac
@adrianholovaty adrianholovaty authored
View
2  django/core/management.py
@@ -290,7 +290,7 @@ def get_sql_delete(app):
output.append('%s %s %s %s;' % \
(style.SQL_KEYWORD('ALTER TABLE'),
style.SQL_TABLE(backend.quote_name(table)),
- style.SQL_KEYWORD('DROP CONSTRAINT'),
+ style.SQL_KEYWORD(backend.get_drop_foreignkey_sql()),
style.SQL_FIELD(backend.quote_name("%s_referencing_%s_%s" % (col, r_table, r_col)))))
del references_to_delete[klass]
View
3  django/db/backends/ado_mssql/base.py
@@ -121,6 +121,9 @@ def get_limit_offset_sql(limit, offset=None):
def get_random_function_sql():
return "RAND()"
+def get_drop_foreignkey_sql():
+ return "DROP CONSTRAINT"
+
OPERATOR_MAPPING = {
'exact': '= %s',
'iexact': 'LIKE %s',
View
1  django/db/backends/dummy/base.py
@@ -33,4 +33,5 @@ def close(self):
get_date_trunc_sql = complain
get_limit_offset_sql = complain
get_random_function_sql = complain
+get_drop_foreignkey_sql = complain
OPERATOR_MAPPING = {}
View
3  django/db/backends/mysql/base.py
@@ -146,6 +146,9 @@ def get_limit_offset_sql(limit, offset=None):
def get_random_function_sql():
return "RAND()"
+def get_drop_foreignkey_sql():
+ return "DROP FOREIGN KEY"
+
OPERATOR_MAPPING = {
'exact': '= %s',
'iexact': 'LIKE %s',
View
3  django/db/backends/postgresql/base.py
@@ -98,6 +98,9 @@ def get_limit_offset_sql(limit, offset=None):
def get_random_function_sql():
return "RANDOM()"
+def get_drop_foreignkey_sql():
+ return "DROP CONSTRAINT"
+
# Register these custom typecasts, because Django expects dates/times to be
# in Python's native (standard-library) datetime/time format, whereas psycopg
# use mx.DateTime by default.
View
3  django/db/backends/sqlite3/base.py
@@ -116,6 +116,9 @@ def get_limit_offset_sql(limit, offset=None):
def get_random_function_sql():
return "RANDOM()"
+def get_drop_foreignkey_sql():
+ return ""
+
def _sqlite_date_trunc(lookup_type, dt):
try:
dt = util.typecast_timestamp(dt)
Please sign in to comment.
Something went wrong with that request. Please try again.