summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2014-04-23 21:38:09 +0200
committerAymeric Augustin <aymeric.augustin@m4x.org>2014-04-23 21:45:49 +0200
commite32e359d6ab4e91bbf8fd67d96a687d0006d38b9 (patch)
tree552ea29f635a0252ad119587f9f46dd26ae2f8ec
parent9bf890f6f9d137d5b86fd9a6a38fb11c5d21b1af (diff)
[1.7.x] Used the same instance of atomic for entry and exit.
Since all state is maintained on the connection at this time and none in the atomic, it doesn't matter, but it could introduce some subtle bugs if the implementation changed in the future. Backport of 0aa4c6c3 from master
-rw-r--r--django/db/backends/schema.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/django/db/backends/schema.py b/django/db/backends/schema.py
index d187c48046..fe28be92bc 100644
--- a/django/db/backends/schema.py
+++ b/django/db/backends/schema.py
@@ -72,7 +72,8 @@ class BaseDatabaseSchemaEditor(object):
def __enter__(self):
self.deferred_sql = []
if self.connection.features.can_rollback_ddl:
- atomic(self.connection.alias).__enter__()
+ self.atomic = atomic(self.connection.alias)
+ self.atomic.__enter__()
return self
def __exit__(self, exc_type, exc_value, traceback):
@@ -80,7 +81,7 @@ class BaseDatabaseSchemaEditor(object):
for sql in self.deferred_sql:
self.execute(sql)
if self.connection.features.can_rollback_ddl:
- atomic(self.connection.alias).__exit__(exc_type, exc_value, traceback)
+ self.atomic.__exit__(exc_type, exc_value, traceback)
# Core utility functions