From 7528c2465b3e56ed094f155bff2a3ab8c89cc84f Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Tue, 8 Dec 2020 22:07:48 -0500 Subject: Implement Oracle SERIALIZABLE + real read of isolation level There's some significant awkwardness in that we can't read the level unless a transaction is started, which normally does not occur unless DML is emitted. The implementation uses the local_transaction_id function to start a transaction. It is not known what the performance impact of this might have, however by default the function is called only once on first connect and later only if the get_isolation_level() method is used. Fixes: #5755 Change-Id: I0453a6b0a49420826707f660931002ba2338fbf0 --- lib/sqlalchemy/testing/suite/test_dialect.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'lib/sqlalchemy/testing/suite') diff --git a/lib/sqlalchemy/testing/suite/test_dialect.py b/lib/sqlalchemy/testing/suite/test_dialect.py index 7f697b915..f860a321b 100644 --- a/lib/sqlalchemy/testing/suite/test_dialect.py +++ b/lib/sqlalchemy/testing/suite/test_dialect.py @@ -122,6 +122,28 @@ class IsolationLevelTest(fixtures.TestBase): eq_(conn.get_isolation_level(), existing) + def test_all_levels(self): + levels = requirements.get_isolation_levels(config) + + all_levels = levels["supported"] + + for level in set(all_levels).difference(["AUTOCOMMIT"]): + with config.db.connect() as conn: + conn.execution_options(isolation_level=level) + + eq_(conn.get_isolation_level(), level) + + trans = conn.begin() + trans.rollback() + + eq_(conn.get_isolation_level(), level) + + with config.db.connect() as conn: + eq_( + conn.get_isolation_level(), + levels["default"], + ) + class AutocommitTest(fixtures.TablesTest): -- cgit v1.2.1