mirror of
https://github.com/django/django.git
synced 2025-07-05 18:29:11 +00:00
[boulder-oracle-sprint] move backend.quote_name to fix quoting
git-svn-id: http://code.djangoproject.com/svn/django/branches/boulder-oracle-sprint@4001 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
b93cd82297
commit
b8431e359b
@ -37,8 +37,7 @@ def create_test_db(settings, connection, backend, verbosity=1, autoclobber=False
|
||||
|
||||
cursor = connection.cursor()
|
||||
try:
|
||||
_create_test_db(cursor, backend.quote_name(TEST_DATABASE_NAME),
|
||||
verbosity)
|
||||
_create_test_db(cursor, backend, TEST_DATABASE_NAME, verbosity)
|
||||
except Exception, e:
|
||||
sys.stderr.write("Got an error creating the test database: %s\n" % e)
|
||||
if not autoclobber:
|
||||
@ -47,12 +46,10 @@ def create_test_db(settings, connection, backend, verbosity=1, autoclobber=False
|
||||
try:
|
||||
if verbosity >= 1:
|
||||
print "Destroying old test database..."
|
||||
_destroy_test_db(cursor, backend.quote_name(TEST_DATABASE_NAME),
|
||||
verbosity)
|
||||
_destroy_test_db(cursor, backend, TEST_DATABASE_NAME, verbosity)
|
||||
if verbosity >= 1:
|
||||
print "Creating test database..."
|
||||
_create_test_db(cursor, backend.quote_name(TEST_DATABASE_NAME),
|
||||
verbosity)
|
||||
_create_test_db(cursor, backend, TEST_DATABASE_NAME, verbosity)
|
||||
except Exception, e:
|
||||
sys.stderr.write("Got an error recreating the test database: %s\n" % e)
|
||||
sys.exit(2)
|
||||
@ -77,18 +74,18 @@ def destroy_test_db(settings, connection, backend, old_database_name, verbosity=
|
||||
|
||||
cursor = connection.cursor()
|
||||
time.sleep(1) # To avoid "database is being accessed by other users" errors.
|
||||
_destroy_test_db(cursor, backend.quote_name(TEST_DATABASE_NAME), verbosity)
|
||||
_destroy_test_db(cursor, backend, TEST_DATABASE_NAME, verbosity)
|
||||
connection.close()
|
||||
|
||||
def _create_test_db(cursor, dbname, verbosity):
|
||||
def _create_test_db(cursor, backend, dbname, verbosity):
|
||||
if verbosity >= 2:
|
||||
print "_create_test_db(): dbname = %s" % dbname
|
||||
statements = [
|
||||
"""create tablespace "%(user)s"
|
||||
datafile '%(user)s.dbf' size 10M autoextend on next 10M maxsize 20M
|
||||
""",
|
||||
"""create temporary tablespace "%(user)s_temp"
|
||||
tempfile '%(user)s_temp.dat' size 10M autoextend on next 10M maxsize 20M
|
||||
"""create temporary tablespace %(user_temp)s
|
||||
tempfile '%(tempfile)s' size 10M autoextend on next 10M maxsize 20M
|
||||
""",
|
||||
"""create user %(user)s
|
||||
identified by %(password)s
|
||||
@ -98,21 +95,24 @@ def _create_test_db(cursor, dbname, verbosity):
|
||||
"""grant resource to %(user)s""",
|
||||
"""grant connect to %(user)s""",
|
||||
]
|
||||
_execute_statements(cursor, statements, dbname, verbosity)
|
||||
_execute_statements(cursor, statements, backend, dbname, verbosity)
|
||||
|
||||
def _destroy_test_db(cursor, dbname, verbosity):
|
||||
def _destroy_test_db(cursor, backend, dbname, verbosity):
|
||||
if verbosity >= 2:
|
||||
print "_destroy_test_db(): dbname=%s" % dbname
|
||||
statements = [
|
||||
"""drop user %(user)s cascade""",
|
||||
"""drop tablespace %(user)s including contents and datafiles cascade constraints""",
|
||||
"""drop tablespace %(user)s_temp including contents and datafiles cascade constraints""",
|
||||
"""drop tablespace %(user_temp)s including contents and datafiles cascade constraints""",
|
||||
]
|
||||
_execute_statements(cursor, statements, dbname, verbosity)
|
||||
_execute_statements(cursor, statements, backend, dbname, verbosity)
|
||||
|
||||
def _execute_statements(cursor, statements, dbname, verbosity):
|
||||
def _execute_statements(cursor, statements, backend, dbname, verbosity):
|
||||
for template in statements:
|
||||
stmt = template % {'user': dbname, 'password': "Im a lumberjack"}
|
||||
stmt = template % {'user': backend.quote_name(dbname),
|
||||
'user_temp': backend.quote_name(dbname + '_temp'),
|
||||
'tempfile': dbname + '_temp.dat'
|
||||
'password': "Im a lumberjack"}
|
||||
if verbosity >= 2:
|
||||
print stmt
|
||||
try:
|
||||
|
Loading…
x
Reference in New Issue
Block a user