summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2013-03-05 20:40:57 +0100
committerAymeric Augustin <aymeric.augustin@m4x.org>2013-03-11 14:48:54 +0100
commit14aa563f51c1a8a2ece52ca6b9e66aed9c89c0fd (patch)
treea1e7112851a61a4b8b81c3a5885796ff8fdcb6e1
parent5e27debc5cba30c84f99151a84c5fd846a65b091 (diff)
Removed superfluous code now that connections use autocommit by default.
-rw-r--r--django/db/backends/creation.py15
-rw-r--r--django/db/backends/postgresql_psycopg2/creation.py8
2 files changed, 1 insertions, 22 deletions
diff --git a/django/db/backends/creation.py b/django/db/backends/creation.py
index aa4fb82b12..c0d0a5958b 100644
--- a/django/db/backends/creation.py
+++ b/django/db/backends/creation.py
@@ -383,10 +383,7 @@ class BaseDatabaseCreation(object):
qn = self.connection.ops.quote_name
- # Create the test database and connect to it. We need to autocommit
- # if the database supports it because PostgreSQL doesn't allow
- # CREATE/DROP DATABASE statements within transactions.
- self._prepare_for_test_db_ddl()
+ # Create the test database and connect to it.
cursor = self.connection.cursor()
try:
cursor.execute(
@@ -454,7 +451,6 @@ class BaseDatabaseCreation(object):
# to do so, because it's not allowed to delete a database while being
# connected to it.
cursor = self.connection.cursor()
- self._prepare_for_test_db_ddl()
# Wait to avoid "database is being accessed by other users" errors.
time.sleep(1)
cursor.execute("DROP DATABASE %s"
@@ -472,15 +468,6 @@ class BaseDatabaseCreation(object):
"BaseDatabaseWrapper.", PendingDeprecationWarning, stacklevel=2)
return self.connection.set_autocommit()
- def _prepare_for_test_db_ddl(self):
- """
- Internal implementation - Hook for tasks that should be performed
- before the ``CREATE DATABASE``/``DROP DATABASE`` clauses used by
- testing code to create/ destroy test databases. Needed e.g. in
- PostgreSQL to rollback and close any active transaction.
- """
- pass
-
def sql_table_creation_suffix(self):
"""
SQL to append to the end of the test table creation statements.
diff --git a/django/db/backends/postgresql_psycopg2/creation.py b/django/db/backends/postgresql_psycopg2/creation.py
index e6400d79a1..3ba2158103 100644
--- a/django/db/backends/postgresql_psycopg2/creation.py
+++ b/django/db/backends/postgresql_psycopg2/creation.py
@@ -77,11 +77,3 @@ class DatabaseCreation(BaseDatabaseCreation):
output.append(get_index_sql('%s_%s_like' % (db_table, f.column),
' text_pattern_ops'))
return output
-
- def _prepare_for_test_db_ddl(self):
- """Rollback and close the active transaction."""
- # Make sure there is an open connection.
- self.connection.cursor()
- self.connection.connection.rollback()
- self.connection.connection.set_isolation_level(
- psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT)