diff options
| author | Gord Thompson <gord@gordthompson.com> | 2020-03-12 12:54:37 -0600 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-03-23 13:10:05 -0400 |
| commit | 01299b6bdaf91691923a99fd8c0241dac6abc432 (patch) | |
| tree | 103b6428da3a7059e138d60e601f02a7a6aa9ae7 /test/requirements.py | |
| parent | fd74bd8eea3f3696c43ca0336ed4e437036c43c5 (diff) | |
| download | sqlalchemy-01299b6bdaf91691923a99fd8c0241dac6abc432.tar.gz | |
Implement autocommit isolation level for cx_oracle
As part of this change Oracle also gets the concept of a
default isolation level, however since Oracle does not provide a
fixed method of knowing what the isolation level would be without a
server side transaction actually in progress, for now we hardcode
just to "READ COMMITTED".
Enhanced the test suite for isolation level testing in the dialect
test suite and added features to requirements so that the supported
isolation levels can be reported generically for dialects.
Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com>
Fixes: #5200
Change-Id: I2c4d49da9ff80ccc228c21e196ec9a961de53478
Diffstat (limited to 'test/requirements.py')
| -rw-r--r-- | test/requirements.py | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/test/requirements.py b/test/requirements.py index bddcfc09a..e9fb6a305 100644 --- a/test/requirements.py +++ b/test/requirements.py @@ -369,19 +369,42 @@ class DefaultRequirements(SuiteRequirements): @property def isolation_level(self): return only_on( - ("postgresql", "sqlite", "mysql", "mssql"), + ("postgresql", "sqlite", "mysql", "mssql", "oracle"), "DBAPI has no isolation level support", ) + fails_on( "postgresql+pypostgresql", "pypostgresql bombs on multiple isolation level calls", ) + def get_isolation_levels(self, config): + levels = set(config.db.dialect._isolation_lookup) + + if against(config, "sqlite"): + default = "SERIALIZABLE" + elif against(config, "postgresql"): + default = "READ COMMITTED" + levels.add("AUTOCOMMIT") + elif against(config, "mysql"): + default = "REPEATABLE READ" + levels.add("AUTOCOMMIT") + elif against(config, "mssql"): + default = "READ COMMITTED" + levels.add("AUTOCOMMIT") + elif against(config, "oracle"): + default = "READ COMMITTED" + levels.add("AUTOCOMMIT") + else: + raise NotImplementedError() + + return {"default": default, "supported": levels} + @property def autocommit(self): """target dialect supports 'AUTOCOMMIT' as an isolation_level""" - return only_on( - ("postgresql", "mysql", "mssql+pyodbc", "mssql+pymssql"), - "dialect does not support AUTOCOMMIT isolation mode", + + return self.isolation_level + only_if( + lambda config: "AUTOCOMMIT" + in self.get_isolation_levels(config)["supported"] ) @property |
