Django

Code

Changeset 3673

Show
Ignore:
Timestamp:
08/28/06 13:59:54 (2 years ago)
Author:
jacob
Message:

Test database creation/deletion now correctly quotes database names when creating/dropping them.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/test/utils.py

    r3658 r3673  
    11import sys, time 
    22from django.conf import settings 
    3 from django.db import connection, transaction 
     3from django.db import connection, transaction, backend 
    44 
    55# The prefix to put on the default database name when creating 
     
    3030        _set_autocommit(connection) 
    3131        try: 
    32             cursor.execute("CREATE DATABASE %s" % TEST_DATABASE_NAME
     32            cursor.execute("CREATE DATABASE %s" % backend.quote_name(TEST_DATABASE_NAME)
    3333        except Exception, e:             
    3434            sys.stderr.write("Got an error creating the test database: %s\n" % e) 
     
    3939                    if verbosity >= 1: 
    4040                        print "Destroying old test database..."                 
    41                     cursor.execute("DROP DATABASE %s" % TEST_DATABASE_NAME
     41                    cursor.execute("DROP DATABASE %s" % backend.quote_name(TEST_DATABASE_NAME)
    4242                    if verbosity >= 1: 
    4343                        print "Creating test database..." 
    44                     cursor.execute("CREATE DATABASE %s" % TEST_DATABASE_NAME
     44                    cursor.execute("CREATE DATABASE %s" % backend.quote_name(TEST_DATABASE_NAME)
    4545                except Exception, e: 
    4646                    sys.stderr.write("Got an error recreating the test database: %s\n" % e) 
     
    7474        _set_autocommit(connection) 
    7575        time.sleep(1) # To avoid "database is being accessed by other users" errors. 
    76         cursor.execute("DROP DATABASE %s" % TEST_DATABASE_NAME
     76        cursor.execute("DROP DATABASE %s" % backend.quote_name(TEST_DATABASE_NAME)
    7777        connection.close() 
    7878