diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-12-18 09:28:06 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-12-18 10:48:30 -0500 |
| commit | 566f1b520e05659ba4d4928c740a9aa1b0fed614 (patch) | |
| tree | 9b87db804c34627badb6a58f416cfe92e18cea54 /lib/sqlalchemy/engine/default.py | |
| parent | 35b04a5508e06a99941cf6eca7de545554c9d6ca (diff) | |
| download | sqlalchemy-566f1b520e05659ba4d4928c740a9aa1b0fed614.tar.gz | |
Gracefully degrade on v$transaction not readable
Fixed regression which occured due to [ticket:5755] which implemented
isolation level support for Oracle. It has been reported that many Oracle
accounts don't actually have permission to query the ``v$transaction``
view so this feature has been altered to gracefully fallback when it fails
upon database connect, where the dialect will assume "READ COMMITTED" is
the default isolation level as was the case prior to SQLAlchemy 1.3.21.
However, explicit use of the :meth:`_engine.Connection.get_isolation_level`
method must now necessarily raise an exception, as Oracle databases with
this restriction explicitly disallow the user from reading the current
isolation level.
Fixes: #5784
Change-Id: Iefc82928744f3c944c18ae8000eb3c9e52e523bc
Diffstat (limited to 'lib/sqlalchemy/engine/default.py')
| -rw-r--r-- | lib/sqlalchemy/engine/default.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/sqlalchemy/engine/default.py b/lib/sqlalchemy/engine/default.py index 59a4b47dc..a754ebe58 100644 --- a/lib/sqlalchemy/engine/default.py +++ b/lib/sqlalchemy/engine/default.py @@ -367,7 +367,7 @@ class DefaultDialect(interfaces.Dialect): self.default_schema_name = None try: - self.default_isolation_level = self.get_isolation_level( + self.default_isolation_level = self.get_default_isolation_level( connection.connection ) except NotImplementedError: @@ -419,6 +419,22 @@ class DefaultDialect(interfaces.Dialect): """ return None + def get_default_isolation_level(self, dbapi_conn): + """Given a DBAPI connection, return its isolation level, or + a default isolation level if one cannot be retrieved. + + May be overridden by subclasses in order to provide a + "fallback" isolation level for databases that cannot reliably + retrieve the actual isolation level. + + By default, calls the :meth:`_engine.Interfaces.get_isolation_level` + method, propagating any exceptions raised. + + .. versionadded:: 1.3.22 + + """ + return self.get_isolation_level(dbapi_conn) + def _check_unicode_returns(self, connection, additional_tests=None): # this now runs in py2k only and will be removed in 2.0; disabled for # Python 3 in all cases under #5315 |
