Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Refactored get_drop_foreignkey_sql() to DatabaseOperations.drop_forei…

…gnkey_sql(). Refs #5106

git-svn-id: http://code.djangoproject.com/svn/django/trunk@5956 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 23a736dca9b2a631e841a9daff067558206e7965 1 parent 8e84d35
Adrian Holovaty authored August 19, 2007
2  django/core/management/sql.py
@@ -147,7 +147,7 @@ def sql_delete(app, style):
147 147
                     output.append('%s %s %s %s;' % \
148 148
                         (style.SQL_KEYWORD('ALTER TABLE'),
149 149
                         style.SQL_TABLE(backend.quote_name(table)),
150  
-                        style.SQL_KEYWORD(backend.get_drop_foreignkey_sql()),
  150
+                        style.SQL_KEYWORD(connection.ops.drop_foreignkey_sql()),
151 151
                         style.SQL_FIELD(truncate_name(r_name, backend.get_max_name_length()))))
152 152
                 del references_to_delete[model]
153 153
             if model._meta.has_auto_field and hasattr(backend, 'get_drop_sequence'):
6  django/db/backends/__init__.py
@@ -85,3 +85,9 @@ def deferrable_sql(self):
85 85
         during a CREATE TABLE statement.
86 86
         """
87 87
         return ''
  88
+
  89
+    def drop_foreignkey_sql(self):
  90
+        """
  91
+        Returns the SQL command that drops a foreign key.
  92
+        """
  93
+        return "DROP CONSTRAINT"
3  django/db/backends/ado_mssql/base.py
@@ -113,9 +113,6 @@ def get_random_function_sql():
113 113
 def get_fulltext_search_sql(field_name):
114 114
     raise NotImplementedError
115 115
 
116  
-def get_drop_foreignkey_sql():
117  
-    return "DROP CONSTRAINT"
118  
-
119 116
 def get_pk_default_value():
120 117
     return "DEFAULT"
121 118
 
1  django/db/backends/dummy/base.py
@@ -47,7 +47,6 @@ def close(self):
47 47
 get_limit_offset_sql = complain
48 48
 get_random_function_sql = complain
49 49
 get_fulltext_search_sql = complain
50  
-get_drop_foreignkey_sql = complain
51 50
 get_pk_default_value = complain
52 51
 get_max_name_length = ignore
53 52
 get_start_transaction_sql = complain
6  django/db/backends/mysql/base.py
@@ -71,6 +71,9 @@ def date_trunc_sql(self, lookup_type, field_name):
71 71
             sql = "CAST(DATE_FORMAT(%s, '%s') AS DATETIME)" % (field_name, format_str)
72 72
         return sql
73 73
 
  74
+    def drop_foreignkey_sql(self):
  75
+        return "DROP FOREIGN KEY"
  76
+
74 77
 class DatabaseWrapper(BaseDatabaseWrapper):
75 78
     ops = DatabaseOperations()
76 79
 
@@ -164,9 +167,6 @@ def get_random_function_sql():
164 167
 def get_fulltext_search_sql(field_name):
165 168
     return 'MATCH (%s) AGAINST (%%s IN BOOLEAN MODE)' % field_name
166 169
 
167  
-def get_drop_foreignkey_sql():
168  
-    return "DROP FOREIGN KEY"
169  
-
170 170
 def get_pk_default_value():
171 171
     return "DEFAULT"
172 172
 
6  django/db/backends/mysql_old/base.py
@@ -81,6 +81,9 @@ def date_trunc_sql(self, lookup_type, field_name):
81 81
             sql = "CAST(DATE_FORMAT(%s, '%s') AS DATETIME)" % (field_name, format_str)
82 82
         return sql
83 83
 
  84
+    def drop_foreignkey_sql(self):
  85
+        return "DROP FOREIGN KEY"
  86
+
84 87
 class DatabaseWrapper(BaseDatabaseWrapper):
85 88
     ops = DatabaseOperations()
86 89
 
@@ -183,9 +186,6 @@ def get_random_function_sql():
183 186
 def get_fulltext_search_sql(field_name):
184 187
     return 'MATCH (%s) AGAINST (%%s IN BOOLEAN MODE)' % field_name
185 188
 
186  
-def get_drop_foreignkey_sql():
187  
-    return "DROP FOREIGN KEY"
188  
-
189 189
 def get_pk_default_value():
190 190
     return "DEFAULT"
191 191
 
3  django/db/backends/oracle/base.py
@@ -189,9 +189,6 @@ def get_random_function_sql():
189 189
 def get_fulltext_search_sql(field_name):
190 190
     raise NotImplementedError
191 191
 
192  
-def get_drop_foreignkey_sql():
193  
-    return "DROP CONSTRAINT"
194  
-
195 192
 def get_pk_default_value():
196 193
     return "DEFAULT"
197 194
 
3  django/db/backends/postgresql/base.py
@@ -143,9 +143,6 @@ def get_random_function_sql():
143 143
 def get_fulltext_search_sql(field_name):
144 144
     raise NotImplementedError
145 145
 
146  
-def get_drop_foreignkey_sql():
147  
-    return "DROP CONSTRAINT"
148  
-
149 146
 def get_pk_default_value():
150 147
     return "DEFAULT"
151 148
 
3  django/db/backends/postgresql_psycopg2/base.py
@@ -97,9 +97,6 @@ def get_random_function_sql():
97 97
 def get_fulltext_search_sql(field_name):
98 98
     raise NotImplementedError
99 99
 
100  
-def get_drop_foreignkey_sql():
101  
-    return "DROP CONSTRAINT"
102  
-
103 100
 def get_pk_default_value():
104 101
     return "DEFAULT"
105 102
 
6  django/db/backends/sqlite3/base.py
@@ -45,6 +45,9 @@ def date_trunc_sql(self, lookup_type, field_name):
45 45
         # function django_date_trunc that's registered in connect().
46 46
         return 'django_date_trunc("%s", %s)' % (lookup_type.lower(), field_name)
47 47
 
  48
+    def drop_foreignkey_sql(self):
  49
+        return ""
  50
+
48 51
 class DatabaseWrapper(BaseDatabaseWrapper):
49 52
     ops = DatabaseOperations()
50 53
 
@@ -127,9 +130,6 @@ def get_random_function_sql():
127 130
 def get_fulltext_search_sql(field_name):
128 131
     raise NotImplementedError
129 132
 
130  
-def get_drop_foreignkey_sql():
131  
-    return ""
132  
-
133 133
 def get_pk_default_value():
134 134
     return "NULL"
135 135
 

0 notes on commit 23a736d

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