1
0
mirror of https://github.com/django/django.git synced 2025-10-28 16:16:12 +00:00

boulder-oracle-sprint: Fixed sqlclear trying to drop sequences for

tables without AutoFields.  Fixed output of sql, sqlall, sqlreset, and 
sqlflush for piping to SQL*Plus.


git-svn-id: http://code.djangoproject.com/svn/django/branches/boulder-oracle-sprint@5136 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Boulder Sprinters
2007-05-02 16:30:00 +00:00
parent 90740c93e6
commit 750d2e8c3c
2 changed files with 10 additions and 5 deletions

View File

@@ -371,7 +371,7 @@ def get_sql_delete(app):
style.SQL_KEYWORD(backend.get_drop_foreignkey_sql()),
style.SQL_FIELD(truncate_name(r_name, backend.get_max_name_length()))))
del references_to_delete[model]
if hasattr(backend, 'get_drop_sequence'):
if model._meta.has_auto_field and hasattr(backend, 'get_drop_sequence'):
output.append(backend.get_drop_sequence(model._meta.db_table))
# Output DROP TABLE statements for many-to-many tables.

View File

@@ -95,8 +95,11 @@ class FormatStylePlaceholderCursor(Database.Cursor):
params[i] = str(param)
args = [(':arg%d' % i) for i in range(len(params))]
query = query % tuple(args)
# cx_Oracle cannot execute a query with the closing ';'
if query.endswith(';'):
# cx_Oracle wants no trailing ';' for SQL statements. For PL/SQL, it
# it does want a trailing ';' but not a trailing '/'. However, these
# characters must be included in the original query in case the query
# is being passed to SQL*Plus.
if query.endswith(';') or query.endswith('/'):
query = query[:-1]
return query, params
@@ -185,7 +188,8 @@ def get_autoinc_sql(table):
WHEN (new.id IS NULL)
BEGIN
SELECT %s.nextval INTO :new.id FROM dual;
END;\n""" % (tr_name, quote_name(table), sq_name)
END;
/""" % (tr_name, quote_name(table), sq_name)
return sequence_sql, trigger_sql
def get_drop_sequence(table):
@@ -208,7 +212,8 @@ def _get_sequence_reset_sql():
EXECUTE IMMEDIATE 'ALTER SEQUENCE %(sequence)s INCREMENT BY 1';
END IF;
COMMIT;
END;\n"""
END;
/"""
def get_sql_flush(style, tables, sequences):
"""Return a list of SQL statements required to remove all data from