diff options
| author | Ants Aasma <ants.aasma@gmail.com> | 2008-09-30 09:24:27 +0000 |
|---|---|---|
| committer | Ants Aasma <ants.aasma@gmail.com> | 2008-09-30 09:24:27 +0000 |
| commit | 4c53406cab9bef94331bd060a8f3ab3f5faee754 (patch) | |
| tree | 0b0641b2dffcdbbc5dac9fe24afeafa2602f48dc /lib | |
| parent | 6122c3ad4802040a885f61ae97ecac03605057b4 (diff) | |
| download | sqlalchemy-4c53406cab9bef94331bd060a8f3ab3f5faee754.tar.gz | |
Fixed session.transaction.commit() on a autocommit=False session not starting a new transaction.
Moved starting a new transaction in case of previous closing into SessionTransaction.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/sqlalchemy/orm/session.py | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/lib/sqlalchemy/orm/session.py b/lib/sqlalchemy/orm/session.py index 0ca59141e..cbff0ef0d 100644 --- a/lib/sqlalchemy/orm/session.py +++ b/lib/sqlalchemy/orm/session.py @@ -428,6 +428,8 @@ class SessionTransaction(object): connection.close() else: transaction.close() + if not self.session.autocommit: + self.session.begin() self._deactivate() self.session = None self._connections = None @@ -641,8 +643,6 @@ class Session(object): pass else: self.transaction.rollback() - if self.transaction is None and not self.autocommit: - self.begin() def commit(self): """Flush pending changes and commit the current transaction. @@ -667,8 +667,6 @@ class Session(object): raise sa_exc.InvalidRequestError("No transaction is begun.") self.transaction.commit() - if self.transaction is None and not self.autocommit: - self.begin() def prepare(self): """Prepare the current transaction in progress for two phase commit. @@ -772,9 +770,6 @@ class Session(object): if self.transaction is not None: for transaction in self.transaction._iterate_parents(): transaction.close() - if not self.autocommit: - # note this doesnt use any connection resources - self.begin() def close_all(cls): """Close *all* sessions in memory.""" |
