From 07cc4ecf05aeb746a54ce51671d7a4b2669141e2 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Mon, 25 Feb 2013 19:27:07 -0500 Subject: - A clear error message is emitted if an event handler attempts to emit SQL on a Session within the after_commit() handler, where there is not a viable transaction in progress. [ticket:2662] - rework how SessionTransaction maintains state, using symbols instead. - add lots of notes and cross-linking for session events. - add a link to :func:`.select()` within :meth:`.FromClause.select`. --- test/orm/test_transaction.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test') diff --git a/test/orm/test_transaction.py b/test/orm/test_transaction.py index 28735bd11..7df6ecf91 100644 --- a/test/orm/test_transaction.py +++ b/test/orm/test_transaction.py @@ -358,6 +358,18 @@ class SessionTransactionTest(FixtureTest): sess.begin, subtransactions=True) sess.close() + def test_no_sql_during_prepare(self): + sess = create_session(bind=testing.db, autocommit=False) + + @event.listens_for(sess, "after_commit") + def go(session): + session.execute("select 1") + assert_raises_message(sa_exc.InvalidRequestError, + "This session is in 'prepared' state, where no " + "further SQL can be emitted until the " + "transaction is fully committed.", + sess.commit) + def _inactive_flushed_session_fixture(self): users, User = self.tables.users, self.classes.User -- cgit v1.2.1