Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Test database creation/deletion now correctly quotes database names w…

…hen creating/dropping them.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@3673 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 56264160a2c8fbbe4e36d7c3f804115b8f2e66a2 1 parent a547ef0
Jacob Kaplan-Moss authored

Showing 1 changed file with 5 additions and 5 deletions. Show diff stats Hide diff stats

  1. 10  django/test/utils.py
10  django/test/utils.py
... ...
@@ -1,6 +1,6 @@
1 1
 import sys, time
2 2
 from django.conf import settings
3  
-from django.db import connection, transaction
  3
+from django.db import connection, transaction, backend
4 4
 
5 5
 # The prefix to put on the default database name when creating
6 6
 # the test database.
@@ -29,7 +29,7 @@ def create_test_db(verbosity=1, autoclobber=False):
29 29
         cursor = connection.cursor()
30 30
         _set_autocommit(connection)
31 31
         try:
32  
-            cursor.execute("CREATE DATABASE %s" % TEST_DATABASE_NAME)
  32
+            cursor.execute("CREATE DATABASE %s" % backend.quote_name(TEST_DATABASE_NAME))
33 33
         except Exception, e:            
34 34
             sys.stderr.write("Got an error creating the test database: %s\n" % e)
35 35
             if not autoclobber:
@@ -38,10 +38,10 @@ def create_test_db(verbosity=1, autoclobber=False):
38 38
                 try:
39 39
                     if verbosity >= 1:
40 40
                         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))
42 42
                     if verbosity >= 1:
43 43
                         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))
45 45
                 except Exception, e:
46 46
                     sys.stderr.write("Got an error recreating the test database: %s\n" % e)
47 47
                     sys.exit(2)
@@ -73,6 +73,6 @@ def destroy_test_db(old_database_name, verbosity=1):
73 73
         cursor = connection.cursor()
74 74
         _set_autocommit(connection)
75 75
         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))
77 77
         connection.close()
78 78
 

0 notes on commit 5626416

Please sign in to comment.
Something went wrong with that request. Please try again.