diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-02-25 19:27:07 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-02-25 19:27:07 -0500 |
| commit | 07cc4ecf05aeb746a54ce51671d7a4b2669141e2 (patch) | |
| tree | 45d320b5157083f0e8d6d927f36bf796b48d16a7 /test | |
| parent | 95297c35442e483bb98b5a4edb677bb168064f5e (diff) | |
| download | sqlalchemy-07cc4ecf05aeb746a54ce51671d7a4b2669141e2.tar.gz | |
- 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`.
Diffstat (limited to 'test')
| -rw-r--r-- | test/orm/test_transaction.py | 12 |
1 files changed, 12 insertions, 0 deletions
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 |
