diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-03-03 15:32:14 +0100 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-03-11 14:48:54 +0100 |
| commit | cd364efa00dba5aa86187aee83e4ed9917e7e93c (patch) | |
| tree | 37a219abd44c7ab368bad523e5887efbbe7ba00b | |
| parent | af9e9386eb6ad22e3fa822574a4f5be4c9c29771 (diff) | |
Stopped flipping the uses_savepoints feature at runtime.
| -rw-r--r-- | django/db/backends/__init__.py | 6 | ||||
| -rw-r--r-- | django/db/backends/postgresql_psycopg2/base.py | 5 |
2 files changed, 4 insertions, 7 deletions
diff --git a/django/db/backends/__init__.py b/django/db/backends/__init__.py index afa01158c2..ada0e038b4 100644 --- a/django/db/backends/__init__.py +++ b/django/db/backends/__init__.py @@ -161,17 +161,17 @@ class BaseDatabaseWrapper(object): ##### Backend-specific savepoint management methods ##### def _savepoint(self, sid): - if not self.features.uses_savepoints: + if not self.features.uses_savepoints or self.autocommit: return self.cursor().execute(self.ops.savepoint_create_sql(sid)) def _savepoint_rollback(self, sid): - if not self.features.uses_savepoints: + if not self.features.uses_savepoints or self.autocommit: return self.cursor().execute(self.ops.savepoint_rollback_sql(sid)) def _savepoint_commit(self, sid): - if not self.features.uses_savepoints: + if not self.features.uses_savepoints or self.autocommit: return self.cursor().execute(self.ops.savepoint_commit_sql(sid)) diff --git a/django/db/backends/postgresql_psycopg2/base.py b/django/db/backends/postgresql_psycopg2/base.py index 93c5f3c677..385206221d 100644 --- a/django/db/backends/postgresql_psycopg2/base.py +++ b/django/db/backends/postgresql_psycopg2/base.py @@ -49,6 +49,7 @@ class DatabaseFeatures(BaseDatabaseFeatures): has_select_for_update = True has_select_for_update_nowait = True has_bulk_insert = True + uses_savepoints = True supports_tablespaces = True supports_transactions = True can_distinct_on_fields = True @@ -88,8 +89,6 @@ class DatabaseWrapper(BaseDatabaseWrapper): self.introspection = DatabaseIntrospection(self) self.validation = BaseDatabaseValidation(self) - self.features.uses_savepoints = False - def get_connection_params(self): settings_dict = self.settings_dict if not settings_dict['NAME']: @@ -174,7 +173,6 @@ class DatabaseWrapper(BaseDatabaseWrapper): self.cursor().close() if managed and self.autocommit: self.set_autocommit(False) - self.features.uses_savepoints = True def _leave_transaction_management(self, managed): """ @@ -186,7 +184,6 @@ class DatabaseWrapper(BaseDatabaseWrapper): if not managed and not self.autocommit: self.rollback() # Must terminate transaction first. self.set_autocommit(True) - self.features.uses_savepoints = False def _set_isolation_level(self, isolation_level): assert isolation_level in range(1, 5) # Use set_autocommit for level = 0 |
