Closed kotofos closed 2 years ago
The behaviour you noted is intended. Instead of looking for a list of specific erorr codes (which can vary over time and may not be complete) the code was modified to raise a single exception (DPI-1080) which covers all of those scenarios (both now and in the future). It looks like SQLAlchemy has covered one case (DPI-1010: not connected) which is raised after the connection has already been closed (either explicitly by the user or because of connection failures). It should be adjusted to look for DPI-1080 as well (as I see is happening with the proposed patch).
Currently the error code is only populated when an Oracle error is generated. When a cx_Oracle or ODPI-C specific error message is raised the error code is not populated. If we could go back in time the error code would be a string (ORA-3113, DPI-1010, DPI-1080) but changing that now would be disruptive. Putting the DPI error code in there could be confusing as well since the error numbers could potentially overlap. So what we are doing in our own test suite is to look at the beginning of the message. The form is always XXX-NNNN:
where XXX
is one or ORA/DPI/etc. and NNNN
is a number.
I'll close this since SQLAlchemy has implemented the solution. Thanks for reporting the problem.
We have the addition of an attribute to show the prefix + code on our (long) TODO list.
cx_oracle 8.3
platform.platform: Linux-5.3.18-59.37-preempt-x86_64-with-glibc2.31 sys.maxsize > 2**32: True platform.python_version: 3.9.8 cx_Oracle.version: 8.3.0 cx_Oracle.clientversion: (19, 6, 0, 0, 0)
Oracle server 19 EE docker image container-registry.oracle.com/database/enterprise:19.3.0.0
Error
Oracle's error code is not set in exception object. This makes harder to get the code value. Especially in sqlachemy cx_oracle dialect. It breaks reconnect workflow.
See sqlalchemy.dialects.oracle.cx_oracle.OracleDialect_cx_oracle.is_disconnect
This behavior changed in cx_oracle 8.2. 8.1 is fine. bug report for sqlachemy https://github.com/sqlalchemy/sqlalchemy/issues/7748
output