mirror of https://github.com/django/django.git
Refactored get_drop_sequence() to DatabaseOperations.drop_sequence_sql(). Refs #5106
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5978 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
4c5248f98f
commit
b105a52882
|
@ -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
|
||||
|
||||
|
|
|
@ -103,6 +103,13 @@ class BaseDatabaseOperations(object):
|
|||
"""
|
||||
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
|
||||
|
|
|
@ -66,6 +66,9 @@ class DatabaseOperations(BaseDatabaseOperations):
|
|||
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 """
|
||||
|
|
Loading…
Reference in New Issue