diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-04-07 19:21:01 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-04-07 19:21:01 -0400 |
| commit | 978755e851e505e2715e71efcb51b0904ded9f80 (patch) | |
| tree | a5b6202c2f94bd98ce8c1d9f2e79f115b6ffadb8 /test | |
| parent | 5150ef4ed166042b4a1f4a77b5a0af609b5fc660 (diff) | |
| download | sqlalchemy-978755e851e505e2715e71efcb51b0904ded9f80.tar.gz | |
Gracefully skip isolation level if no row returned
Fixed issue in MySQL dialect when connecting to a psuedo-MySQL database
such as that provided by ProxySQL, the up front check for isolation level
when it returns no row will not prevent the dialect from continuing to
connect. A warning is emitted that the isolation level could not be
detected.
Fixes: #5239
Change-Id: I4a240386a0d38bd90733819495ce50e37fe2234c
Diffstat (limited to 'test')
| -rw-r--r-- | test/dialect/mysql/test_dialect.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/dialect/mysql/test_dialect.py b/test/dialect/mysql/test_dialect.py index c641411e1..cf0e0b02d 100644 --- a/test/dialect/mysql/test_dialect.py +++ b/test/dialect/mysql/test_dialect.py @@ -194,6 +194,32 @@ class DialectTest(fixtures.TestBase): ): engine.connect() + def test_no_default_isolation_level(self): + from sqlalchemy.testing import mock + + engine = engines.testing_engine() + + real_isolation_level = testing.db.dialect.get_isolation_level + + def fake_isolation_level(connection): + connection = mock.Mock( + cursor=mock.Mock( + return_value=mock.Mock( + fetchone=mock.Mock(return_value=None) + ) + ) + ) + return real_isolation_level(connection) + + with mock.patch.object( + engine.dialect, "get_isolation_level", fake_isolation_level + ): + with expect_warnings( + "Could not retrieve transaction isolation level for MySQL " + "connection." + ): + engine.connect() + def test_autocommit_isolation_level(self): c = testing.db.connect().execution_options( isolation_level="AUTOCOMMIT" |
