Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
Adrian Holovaty authored April 23, 2006
2  django/core/management.py
@@ -290,7 +290,7 @@ def get_sql_delete(app):
290 290
                     output.append('%s %s %s %s;' % \
291 291
                         (style.SQL_KEYWORD('ALTER TABLE'),
292 292
                         style.SQL_TABLE(backend.quote_name(table)),
293  
-                        style.SQL_KEYWORD('DROP CONSTRAINT'),
  293
+                        style.SQL_KEYWORD(backend.get_drop_foreignkey_sql()),
294 294
                         style.SQL_FIELD(backend.quote_name("%s_referencing_%s_%s" % (col, r_table, r_col)))))
295 295
                 del references_to_delete[klass]
296 296
 
3  django/db/backends/ado_mssql/base.py
@@ -121,6 +121,9 @@ def get_limit_offset_sql(limit, offset=None):
121 121
 def get_random_function_sql():
122 122
     return "RAND()"
123 123
 
  124
+def get_drop_foreignkey_sql():
  125
+    return "DROP CONSTRAINT"
  126
+
124 127
 OPERATOR_MAPPING = {
125 128
     'exact': '= %s',
126 129
     'iexact': 'LIKE %s',
1  django/db/backends/dummy/base.py
@@ -33,4 +33,5 @@ def close(self):
33 33
 get_date_trunc_sql = complain
34 34
 get_limit_offset_sql = complain
35 35
 get_random_function_sql = complain
  36
+get_drop_foreignkey_sql = complain
36 37
 OPERATOR_MAPPING = {}
3  django/db/backends/mysql/base.py
@@ -146,6 +146,9 @@ def get_limit_offset_sql(limit, offset=None):
146 146
 def get_random_function_sql():
147 147
     return "RAND()"
148 148
 
  149
+def get_drop_foreignkey_sql():
  150
+    return "DROP FOREIGN KEY"
  151
+
149 152
 OPERATOR_MAPPING = {
150 153
     'exact': '= %s',
151 154
     'iexact': 'LIKE %s',
3  django/db/backends/postgresql/base.py
@@ -98,6 +98,9 @@ def get_limit_offset_sql(limit, offset=None):
98 98
 def get_random_function_sql():
99 99
     return "RANDOM()"
100 100
 
  101
+def get_drop_foreignkey_sql():
  102
+    return "DROP CONSTRAINT"
  103
+
101 104
 # Register these custom typecasts, because Django expects dates/times to be
102 105
 # in Python's native (standard-library) datetime/time format, whereas psycopg
103 106
 # use mx.DateTime by default.
3  django/db/backends/sqlite3/base.py
@@ -116,6 +116,9 @@ def get_limit_offset_sql(limit, offset=None):
116 116
 def get_random_function_sql():
117 117
     return "RANDOM()"
118 118
 
  119
+def get_drop_foreignkey_sql():
  120
+    return ""
  121
+
119 122
 def _sqlite_date_trunc(lookup_type, dt):
120 123
     try:
121 124
         dt = util.typecast_timestamp(dt)

0 notes on commit 121c9c9

Please sign in to comment.
Something went wrong with that request. Please try again.