]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Check cx_Oracle error code on all exception classes
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 6 Feb 2018 20:47:43 +0000 (15:47 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 7 Feb 2018 00:38:59 +0000 (19:38 -0500)
Fixed bug in cx_Oracle disconnect detection, used by pre_ping and other
features, where an error could be raised as DatabaseError which includes a
numeric error code; previously we weren't checking in this case for a
disconnect code.

Change-Id: I359bb5ede25a4726ea632b81af83c6391f405ae1
Fixes: #4182
doc/build/changelog/unreleased_12/4182.rst [new file with mode: 0644]
lib/sqlalchemy/dialects/oracle/cx_oracle.py
test/engine/test_execute.py
test/requirements.py

diff --git a/doc/build/changelog/unreleased_12/4182.rst b/doc/build/changelog/unreleased_12/4182.rst
new file mode 100644 (file)
index 0000000..67126b4
--- /dev/null
@@ -0,0 +1,8 @@
+.. change::
+    :tags: bug, oracle
+    :tickets: 4182
+
+    Fixed bug in cx_Oracle disconnect detection, used by pre_ping and other
+    features, where an error could be raised as DatabaseError which includes a
+    numeric error code; previously we weren't checking in this case for a
+    disconnect code.
index 24655ee1b19f37f1396ad43bbc2513fccdeec219..5f07e869ee68413b614194a32068526f33b75665 100644 (file)
@@ -817,10 +817,13 @@ class OracleDialect_cx_oracle(OracleDialect):
 
     def is_disconnect(self, e, connection, cursor):
         error, = e.args
-        if isinstance(e, (
-                self.dbapi.InterfaceError, self.dbapi.DatabaseError)):
-            return "not connected" in str(e)
-        elif hasattr(error, 'code'):
+        if isinstance(
+                e,
+                (self.dbapi.InterfaceError, self.dbapi.DatabaseError)
+        ) and "not connected" in str(e):
+            return True
+
+        if hasattr(error, 'code'):
             # ORA-00028: your session has been killed
             # ORA-03114: not connected to ORACLE
             # ORA-03113: end-of-file on communication channel
index 5263c79db08add9d109b3d1cdd1a2be83cff10c0..1b79347944872d15966fd29891935bdf7c8b7288 100644 (file)
@@ -1829,7 +1829,8 @@ class HandleErrorTest(fixtures.TestBase):
 
         with expect_warnings(
             r"An exception has occurred during handling of a previous "
-            r"exception.  The previous exception is.*i_dont_exist",
+            r"exception.  The previous exception "
+            r"is.*(?:i_dont_exist|does not exist)",
             py2konly=True
         ):
             with patch.object(conn.dialect, "do_rollback", boom) as patched:
index d7eaec5fdbf3926a23e932a092af0fc22dec10e9..5ae251f9bdcc5ecac99870aaecae757f8bfc6a6f 100644 (file)
@@ -1002,7 +1002,7 @@ class DefaultRequirements(SuiteRequirements):
 
     @property
     def ad_hoc_engines(self):
-        return exclusions.skip_if(["oracle"])
+        return exclusions.open()
 
     @property
     def no_mssql_freetds(self):