oracle / python-oracledb

Python driver for Oracle Database conforming to the Python DB API 2.0 specification. This is the renamed, new major release of cx_Oracle
https://oracle.github.io/python-oracledb
Other
328 stars 66 forks source link

Thin mode: connection.gettype error #123

Closed ivba7 closed 1 year ago

ivba7 commented 1 year ago

oracle 19.0.0.0.0 platform.platform: Linux-4.18.0-425.3.1.el8.x86_64-x86_64-with-glibc2.2.5 sys.maxsize > 2**32: True platform.python_version: 3.8.13 oracledb.version: 1.2.1

Error my_type_1 = tpm_db.conn.gettype( 'TPM.TEST_TYPES.TBL_REC_TRANSACTIONS1')

Traceback (most recent call last): File "test_db_gettype.py", line 19, in my_type_1 = tpm_db.conn.gettype( File "/home/r432107/myenv38/lib64/python3.8/site-packages/oracledb/connection.py", line 441, in gettype obj_type_impl = self._impl.get_type(self, name) File "src/oracledb/impl/thin/connection.pyx", line 361, in oracledb.thin_impl.ThinConnImpl.get_type File "src/oracledb/impl/thin/dbobject.pyx", line 897, in oracledb.thin_impl.ThinDbObjectTypeCache.get_type File "src/oracledb/impl/thin/dbobject.pyx", line 953, in oracledb.thin_impl.ThinDbObjectTypeCache.populate_partial_types File "src/oracledb/impl/thin/dbobject.pyx", line 860, in oracledb.thin_impl.ThinDbObjectTypeCache._populate_type_info File "src/oracledb/impl/thin/dbobject.pyx", line 834, in oracledb.thin_impl.ThinDbObjectTypeCache._parse_tds File "src/oracledb/impl/thin/dbobject.pyx", line 782, in oracledb.thin_impl.ThinDbObjectTypeCache._parse_element_type File "src/oracledb/impl/thin/dbobject.pyx", line 683, in oracledb.thin_impl.ThinDbObjectTypeCache._determine_element_objtype TypeError: 'NoneType' object is not iterable

  1. Does your application call init_oracle_client()? No

  2. Include a runnable Python script that shows the problem.

import common.db as dba
import traceback
import sys
import platform

print("platform.platform:", platform.platform())
print("sys.maxsize > 2**32:", sys.maxsize > 2**32)
print("platform.python_version:", platform.python_version())

import oracledb
print("oracledb.__version__:", oracledb.__version__)

tpm_db = dba.Db(
    'D00TPMOUT', 'xxxx', 'xxx.dctest.slsp.sk:1537/RSKD2TP2', 'utf-8', 1, 1, '')
cur = tpm_db.cursor()

try:
    my_type_1 = tpm_db.conn.gettype(
                'TPM.TEST_TYPES.TBL_REC_TRANSACTIONS1')

    print(f'my_type_1:[{my_type_1}]')
except Exception:
    print(traceback.format_exc(1000))

try:
    my_type= tpm_db.conn.gettype(
                'TPM.TEST_TYPES.TBL_REC_PAY24STS')
    print(f'my_type:[{my_type}]')
except Exception:
    print(traceback.format_exc(1000))
CREATE OR REPLACE PACKAGE test_types
AS

    SUBTYPE rec_transaction IS transactions_ntf_test%ROWTYPE;

    TYPE tbl_rec_transactions1 IS TABLE OF rec_transaction INDEX BY BINARY_INTEGER; 

    TYPE rec_pay24sts IS RECORD(CHANNEL_REF_NO VARCHAR2(50),
                                SRC_CHANNEL VARCHAR2(10),
                                SRC_SYSTEM VARCHAR2(10),
                                IBAN VARCHAR2(34),
                                STATUS VARCHAR2(1),
                                STATUS_DESC VARCHAR2(4000),
                                MSG_ORIG VARCHAR2(4000),
                                MSG_CONV VARCHAR2(32000),
                                SERVICE_NAME VARCHAR2(64),
                                MSG_TYPE VARCHAR2(64),
                                MSG_FORMAT VARCHAR2(8));

    TYPE tbl_rec_pay24sts IS TABLE OF rec_pay24sts INDEX BY BINARY_INTEGER; 
END;
/
GRANT EXECUTE ON test_types TO D00TPMOUT
/

CREATE TABLE transactions_ntf_test
    (seq_no NUMBER ,
    tran_date DATE,
    tran_type VARCHAR2(4 BYTE))
/

GRANT SELECT ON transactions_ntf_test TO D00TPMOUT
/
anthony-tuininga commented 1 year ago

I can replicate the issue. It looks like %ROWTYPE isn't handled properly in thin mode. I'll see what is needed to correct that. Thanks for the report!

anthony-tuininga commented 1 year ago

I have pushed a patch that should correct this issue and added a relevant test case. If you are able to build from source you can verify that it corrects your issue as well.

anthony-tuininga commented 1 year ago

This patch is included in version 1.2.2 which was just released.