1
0
mirror of https://github.com/django/django.git synced 2025-07-04 17:59:13 +00:00

boulder-oracle-sprint: Caught up with refactoring in test/utils.py, so now at

least some of the tests are passing again.


git-svn-id: http://code.djangoproject.com/svn/django/branches/boulder-oracle-sprint@4720 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Boulder Sprinters 2007-03-13 15:33:37 +00:00
parent 0b7dd14d1f
commit ebe27acd14
2 changed files with 41 additions and 8 deletions

View File

@ -45,7 +45,7 @@ class DatabaseWrapper(local):
cursor.arraysize = 256 cursor.arraysize = 256
# set oracle date to ansi date format # set oracle date to ansi date format
cursor.execute("ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD'") cursor.execute("ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD'")
cursor.execute("ALTER SESSION SET NLS_TIMESTAMP_FORMAT = 'YYYY-MM-DD HH24:MI:SS'") cursor.execute("ALTER SESSION SET NLS_TIMESTAMP_FORMAT = 'YYYY-MM-DD HH24:MI:SS.FF'")
return cursor return cursor
def _commit(self): def _commit(self):
@ -181,13 +181,43 @@ def get_sql_flush(style, tables, sequences):
all tables in the database (without actually removing the tables all tables in the database (without actually removing the tables
themselves) and put the database in an empty 'initial' state themselves) and put the database in an empty 'initial' state
""" """
# Return a list of 'TRUNCATE x;', 'TRUNCATE y;', 'TRUNCATE z;'... style SQL statements # Return a list of 'TRUNCATE x;', 'TRUNCATE y;',
# TODO - SQL not actually tested against Oracle yet! # 'TRUNCATE z;'... style SQL statements
# TODO - autoincrement indices reset required? See other get_sql_flush() implementations if tables:
sql = ['%s %s;' % \ sql = ['%s %s %s;' % \
(style.SQL_KEYWORD('TRUNCATE'), (style.SQL_KEYWORD('TRUNCATE'), style.SQL_KEYWORD('TABLE'),
style.SQL_FIELD(quote_name(table)) style.SQL_FIELD(quote_name(table))
) for table in tables] ) for table in tables]
# 'ALTER SEQUENCE sequence_name RESTART WITH 1;'... style SQL statements
# to reset sequence indices
for sequence_info in sequences:
table_name = sequence_info['table']
column_name = sequence_info['column']
if column_name and len(column_name):
# sequence name in this case will be <table>_<column>_seq
sql.append("%s %s %s %s %s %s;" % \
(style.SQL_KEYWORD('ALTER'),
style.SQL_KEYWORD('SEQUENCE'),
style.SQL_FIELD('%s_%s_seq' % (table_name, column_name)),
style.SQL_KEYWORD('RESTART'),
style.SQL_KEYWORD('WITH'),
style.SQL_FIELD('1')
)
)
else:
# sequence name in this case will be <table>_id_seq
sql.append("%s %s %s %s %s %s;" % \
(style.SQL_KEYWORD('ALTER'),
style.SQL_KEYWORD('SEQUENCE'),
style.SQL_FIELD('%s_id_seq' % table_name),
style.SQL_KEYWORD('RESTART'),
style.SQL_KEYWORD('WITH'),
style.SQL_FIELD('1')
)
)
return sql
else:
return []
OPERATOR_MAPPING = { OPERATOR_MAPPING = {
'exact': '= %s', 'exact': '= %s',

View File

@ -1,4 +1,5 @@
import sys, time import sys, time
from django.core import management
# This dictionary maps Field objects to their associated Oracle column # This dictionary maps Field objects to their associated Oracle column
# types, as strings. Column-type strings can contain format strings; they'll # types, as strings. Column-type strings can contain format strings; they'll
@ -108,6 +109,8 @@ def create_test_db(settings, connection, backend, verbosity=1, autoclobber=False
settings.DATABASE_USER = TEST_DATABASE_USER settings.DATABASE_USER = TEST_DATABASE_USER
settings.DATABASE_PASSWORD = TEST_DATABASE_PASSWD settings.DATABASE_PASSWORD = TEST_DATABASE_PASSWD
management.syncdb(verbosity, interactive=False)
# Get a cursor (even though we don't need one yet). This has # Get a cursor (even though we don't need one yet). This has
# the side effect of initializing the test database. # the side effect of initializing the test database.
cursor = connection.cursor() cursor = connection.cursor()