Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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
@adrianholovaty adrianholovaty authored
View
11 django/core/management/sql.py
@@ -151,8 +151,10 @@ def sql_delete(app, style):
style.SQL_KEYWORD(connection.ops.drop_foreignkey_sql()),
style.SQL_FIELD(truncate_name(r_name, connection.ops.max_name_length()))))
del references_to_delete[model]
- if model._meta.has_auto_field and hasattr(backend, 'get_drop_sequence'):
- output.append(backend.get_drop_sequence(model._meta.db_table))
+ if model._meta.has_auto_field:
+ ds = connection.ops.drop_sequence_sql(model._meta.db_table)
+ if ds:
+ output.append(ds)
# Output DROP TABLE statements for many-to-many tables.
for model in app_models:
@@ -161,8 +163,9 @@ def sql_delete(app, style):
if cursor and table_name_converter(f.m2m_db_table()) in table_names:
output.append("%s %s;" % (style.SQL_KEYWORD('DROP TABLE'),
style.SQL_TABLE(qn(f.m2m_db_table()))))
- if hasattr(backend, 'get_drop_sequence'):
- output.append(backend.get_drop_sequence("%s_%s" % (model._meta.db_table, f.column)))
+ ds = connection.ops.drop_sequence_sql("%s_%s" % (model._meta.db_table, f.column))
+ if ds:
+ output.append(ds)
app_label = app_models[0]._meta.app_label
View
7 django/db/backends/__init__.py
@@ -103,6 +103,13 @@ def drop_foreignkey_sql(self):
"""
return "DROP CONSTRAINT"
+ def drop_sequence_sql(self, table):
+ """
+ Returns any SQL necessary to drop the sequence for the given table.
+ Returns None if no SQL is necessary.
+ """
+ return None
+
def field_cast_sql(self, db_type):
"""
Given a column type (e.g. 'BLOB', 'VARCHAR'), returns the SQL necessary
View
6 django/db/backends/oracle/base.py
@@ -66,6 +66,9 @@ def datetime_cast_sql(self):
def deferrable_sql(self):
return " DEFERRABLE INITIALLY DEFERRED"
+ def drop_sequence_sql(self, table):
+ return "DROP SEQUENCE %s;" % self.quote_name(get_sequence_name(table))
+
def field_cast_sql(self, db_type):
if db_type.endswith('LOB'):
return "DBMS_LOB.SUBSTR(%s)"
@@ -468,9 +471,6 @@ def to_unicode(s):
return force_unicode(s)
return s
-def get_drop_sequence(table):
- return "DROP SEQUENCE %s;" % DatabaseOperations().quote_name(get_sequence_name(table))
-
def _get_sequence_reset_sql():
# TODO: colorize this SQL code with style.SQL_KEYWORD(), etc.
return """
Please sign in to comment.
Something went wrong with that request. Please try again.