mapper inheritance against the target mapper are
still not allowed.
+ - Added is_active flag to Sessions to detect when
+ a transaction is in progress [ticket:976]. This
+ flag is always True with a "transactional"
+ (in 0.5 a non-"autocommit") Session.
+
- postgres
- Repaired server_side_cursors to properly detect
text() clauses.
if added or deleted:
return True
return False
-
+
+ def is_active(self):
+ """return True if this Session has an active transaction."""
+
+ return self.transaction and self.transaction.is_active
+ is_active = property(is_active)
+
def _dirty_states(self):
"""Return a set of all persistent states considered dirty.
import inspect
import pickle
from sqlalchemy.orm import create_session, sessionmaker
-from testlib import engines, sa, testing
+from testlib import engines, sa, testing, config
from testlib.sa import Table, Column, Integer, String
from testlib.sa.orm import mapper, relation, backref
from testlib.testing import eq_
session.begin()
session.flush()
session.commit()
+
+ def test_active_flag(self):
+ sess = create_session(bind=config.db, autocommit=True)
+ assert not sess.is_active
+ sess.begin()
+ assert sess.is_active
+ sess.rollback()
+ assert not sess.is_active
@testing.resolve_artifact_names
def test_textual_execute(self):