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_sequence() to DatabaseOperations.drop_sequence_sq…

…l(). Refs #5106

git-svn-id: http://code.djangoproject.com/svn/django/trunk@5978 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit b105a528828377757e3c654bcd3221406409ab25 1 parent 4c5248f
Adrian Holovaty authored August 20, 2007
11  django/core/management/sql.py
@@ -151,8 +151,10 @@ def sql_delete(app, style):
151 151
                         style.SQL_KEYWORD(connection.ops.drop_foreignkey_sql()),
152 152
                         style.SQL_FIELD(truncate_name(r_name, connection.ops.max_name_length()))))
153 153
                 del references_to_delete[model]
154  
-            if model._meta.has_auto_field and hasattr(backend, 'get_drop_sequence'):
155  
-                output.append(backend.get_drop_sequence(model._meta.db_table))
  154
+            if model._meta.has_auto_field:
  155
+                ds = connection.ops.drop_sequence_sql(model._meta.db_table)
  156
+                if ds:
  157
+                    output.append(ds)
156 158
 
157 159
     # Output DROP TABLE statements for many-to-many tables.
158 160
     for model in app_models:
@@ -161,8 +163,9 @@ def sql_delete(app, style):
161 163
             if cursor and table_name_converter(f.m2m_db_table()) in table_names:
162 164
                 output.append("%s %s;" % (style.SQL_KEYWORD('DROP TABLE'),
163 165
                     style.SQL_TABLE(qn(f.m2m_db_table()))))
164  
-                if hasattr(backend, 'get_drop_sequence'):
165  
-                    output.append(backend.get_drop_sequence("%s_%s" % (model._meta.db_table, f.column)))
  166
+                ds = connection.ops.drop_sequence_sql("%s_%s" % (model._meta.db_table, f.column))
  167
+                if ds:
  168
+                    output.append(ds)
166 169
 
167 170
     app_label = app_models[0]._meta.app_label
168 171
 
7  django/db/backends/__init__.py
@@ -103,6 +103,13 @@ def drop_foreignkey_sql(self):
103 103
         """
104 104
         return "DROP CONSTRAINT"
105 105
 
  106
+    def drop_sequence_sql(self, table):
  107
+        """
  108
+        Returns any SQL necessary to drop the sequence for the given table.
  109
+        Returns None if no SQL is necessary.
  110
+        """
  111
+        return None
  112
+
106 113
     def field_cast_sql(self, db_type):
107 114
         """
108 115
         Given a column type (e.g. 'BLOB', 'VARCHAR'), returns the SQL necessary
6  django/db/backends/oracle/base.py
@@ -66,6 +66,9 @@ def datetime_cast_sql(self):
66 66
     def deferrable_sql(self):
67 67
         return " DEFERRABLE INITIALLY DEFERRED"
68 68
 
  69
+    def drop_sequence_sql(self, table):
  70
+        return "DROP SEQUENCE %s;" % self.quote_name(get_sequence_name(table))
  71
+
69 72
     def field_cast_sql(self, db_type):
70 73
         if db_type.endswith('LOB'):
71 74
             return "DBMS_LOB.SUBSTR(%s)"
@@ -468,9 +471,6 @@ def to_unicode(s):
468 471
         return force_unicode(s)
469 472
     return s
470 473
 
471  
-def get_drop_sequence(table):
472  
-    return "DROP SEQUENCE %s;" % DatabaseOperations().quote_name(get_sequence_name(table))
473  
-
474 474
 def _get_sequence_reset_sql():
475 475
     # TODO: colorize this SQL code with style.SQL_KEYWORD(), etc.
476 476
     return """

0 notes on commit b105a52

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