diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-02-27 00:44:26 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-02-27 00:44:26 +0000 |
commit | 46fa536ba4c2542bcac41346bb113a08ebcf342c (patch) | |
tree | 051cca9668a5d1a65c81129399fd7faffde8d2c4 /lib/sqlalchemy/engine/base.py | |
parent | 64988b45656c8fcdf384b3ad3b6303eaff521dc1 (diff) | |
download | sqlalchemy-46fa536ba4c2542bcac41346bb113a08ebcf342c.tar.gz |
- threadlocal engine wasn't properly closing the connection
upon close() - fixed that.
- Transaction object doesn't rollback or commit if it isn't
"active", allows more accurate nesting of begin/rollback/commit.
- Added basic support for mxODBC [ticket:1710].
- Python unicode objects as binds result in the Unicode type,
not string, thus eliminating a certain class of unicode errors
on drivers that don't support unicode binds.
Diffstat (limited to 'lib/sqlalchemy/engine/base.py')
-rw-r--r-- | lib/sqlalchemy/engine/base.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/sqlalchemy/engine/base.py b/lib/sqlalchemy/engine/base.py index ff475ee3d..578bd58d7 100644 --- a/lib/sqlalchemy/engine/base.py +++ b/lib/sqlalchemy/engine/base.py @@ -1287,8 +1287,8 @@ class Transaction(object): def rollback(self): if not self._parent.is_active: return - self.is_active = False self._do_rollback() + self.is_active = False def _do_rollback(self): self._parent.rollback() @@ -1318,10 +1318,12 @@ class RootTransaction(Transaction): self.connection._begin_impl() def _do_rollback(self): - self.connection._rollback_impl() + if self.is_active: + self.connection._rollback_impl() def _do_commit(self): - self.connection._commit_impl() + if self.is_active: + self.connection._commit_impl() class NestedTransaction(Transaction): @@ -1330,10 +1332,12 @@ class NestedTransaction(Transaction): self._savepoint = self.connection._savepoint_impl() def _do_rollback(self): - self.connection._rollback_to_savepoint_impl(self._savepoint, self._parent) + if self.is_active: + self.connection._rollback_to_savepoint_impl(self._savepoint, self._parent) def _do_commit(self): - self.connection._release_savepoint_impl(self._savepoint, self._parent) + if self.is_active: + self.connection._release_savepoint_impl(self._savepoint, self._parent) class TwoPhaseTransaction(Transaction): |