Add support for DB_TYPE_OBJECT in thin mode
Hi, I'm working on a pull request https://github.com/django/django/pull/15841 which replaces the use of cx_Oracle module with oracledb in django.
However, there is a failed test that related to DB_TYPE_OBJECT.
The reason seems to be that DB_TYPE_OBJECT is not supported in oracledb.thin_impl.MessageWithData._process_column_data.
This test could be passed with cx_Oracle. Is it possible to add the same support to oracledb.thin_impl.MessageWithData._process_column_data?
Related codes:
- django/contrib/gis/db/backends/oracle/introspection.py
Here django maps itsGeometryFieldtooracledb.DB_TYPE_OBJECT(previouslycx_Oracle.OBJECT). - django/tests/gis_tests/inspectapp/tests.py
Here is the code to the test.
- What versions are you using? It's an internal database used in the CI of django. I think is version should be 19.
- Is it an error or a hang or a crash? crash
- What error(s) or behavior you are seeing?
Traceback (most recent call last):
File "/home/jenkins/workspace/pull-requests-oracle/database/oragis19/label/oracle/python/python3.10/django/db/backends/utils.py", line 89, in _execute
return self.cursor.execute(sql, params)
File "/home/jenkins/workspace/pull-requests-oracle/database/oragis19/label/oracle/python/python3.10/django/db/backends/oracle/base.py", line 566, in execute
return self.cursor.execute(query, self._param_generator(params))
File "/home/jenkins/workspace/pull-requests-oracle/database/oragis19/label/oracle/python/python3.10/tests/.env/lib/python3.10/site-packages/oracledb/cursor.py", line 378, in execute
impl.execute(self)
File "src/oracledb/impl/thin/cursor.pyx", line 121, in oracledb.thin_impl.ThinCursorImpl.execute
File "src/oracledb/impl/thin/protocol.pyx", line 375, in oracledb.thin_impl.Protocol._process_single_message
File "src/oracledb/impl/thin/protocol.pyx", line 376, in oracledb.thin_impl.Protocol._process_single_message
File "src/oracledb/impl/thin/protocol.pyx", line 336, in oracledb.thin_impl.Protocol._process_message
File "src/oracledb/impl/thin/protocol.pyx", line 315, in oracledb.thin_impl.Protocol._process_message
File "src/oracledb/impl/thin/messages.pyx", line 281, in oracledb.thin_impl.Message.process
File "src/oracledb/impl/thin/messages.pyx", line 789, in oracledb.thin_impl.MessageWithData._process_message
File "src/oracledb/impl/thin/messages.pyx", line 869, in oracledb.thin_impl.MessageWithData._process_row_data
File "src/oracledb/impl/thin/messages.pyx", line 595, in oracledb.thin_impl.MessageWithData._process_column_data
File "/home/jenkins/workspace/pull-requests-oracle/database/oragis19/label/oracle/python/python3.10/tests/.env/lib/python3.10/site-packages/oracledb/errors.py", line 103, in _raise_err
raise exc_type(_Error(message)) from cause
oracledb.exceptions.NotSupportedError: DPY-3007: database type "DB_TYPE_OBJECT" is not supported
- Does your application call init_oracle_client()?
No.
- Include a runnable Python script that shows the problem.
This is a known limitation and one that is intended to be removed in the future. See the appendix in the documentation which provides this information. So I have changed this to be an enhancement. In the meantime, you need to call oracledb.init_oracle_client() to enable thick mode -- which does have this capability.
@petronny you can use Connection.thin to skip the test when the driver is in Thin mode. In the future python-oracledb 1.1 there will also be an is_thin_mode() method.
Also, thanks for creating the Django PR. We had started preparing to create one but are happy for yours to proceed.
@petronny, I have just pushed changes to support binding/fetching data of type DB_TYPE_OBJECT in thin mode. Please give it a whirl and let me know if you run into any problems. Thanks!
@petronny, I have just pushed changes to support binding/fetching data of type DB_TYPE_OBJECT in thin mode. Please give it a whirl and let me know if you run into any problems. Thanks!
How ~do we~ are we meant to do this?
I had issues. Firstly, beta versions haven't been uploaded to PyPI:
$ pip install oracledb==1.2.0b1
ERROR: Could not find a version that satisfies the requirement oracledb==1.2.0b1 (from versions: 1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.1.0, 1.1.1)
ERROR: No matching distribution found for oracledb==1.2.0b1
This seemed to be the only way to get it to work for me:
$ pip install -e git+https://github.com/oracle/python-oracledb.git#egg=oracledb
Obtaining oracledb from git+https://github.com/oracle/python-oracledb.git#egg=oracledb
Cloning https://github.com/oracle/python-oracledb.git to ./.direnv/python-3.6.15/src/oracledb
Running command git clone --filter=blob:none -q https://github.com/oracle/python-oracledb.git ./.direnv/python-3.6.15/src/oracledb
Resolved https://github.com/oracle/python-oracledb.git to commit 3b6232ca7eccb116bf9540f36b635f2650d65e4f
Running command git submodule update --init --recursive -q
Installing build dependencies ... done
Checking if build backend supports build_editable ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: cryptography>=3.2.1 in ./.direnv/python-3.6.15/lib/python3.6/site-packages (from oracledb) (3.3.2)
Requirement already satisfied: cffi>=1.12 in ./.direnv/python-3.6.15/lib/python3.6/site-packages (from cryptography>=3.2.1->oracledb) (1.13.2)
Requirement already satisfied: six>=1.4.1 in ./.direnv/python-3.6.15/lib/python3.6/site-packages (from cryptography>=3.2.1->oracledb) (1.12.0)
Requirement already satisfied: pycparser in ./.direnv/python-3.6.15/lib/python3.6/site-packages (from cffi>=1.12->cryptography>=3.2.1->oracledb) (2.20)
Installing collected packages: oracledb
Attempting uninstall: oracledb
Found existing installation: oracledb 1.1.1
Uninstalling oracledb-1.1.1:
Successfully uninstalled oracledb-1.1.1
Running setup.py develop for oracledb
Successfully installed oracledb-1.2.0b1
The installation docs don't seem to have any hints.
This section of the documentation is what is referred to -- near the bottom of the link you referenced. Glad you got it figured out. If you run into any problems, please let me know! Thanks.
This is part of oracledb 1.2.0 which was just released.