From: Mike Bayer Date: Mon, 2 Dec 2024 23:59:19 +0000 (-0500) Subject: use VARCHAR for CLOB outputtypehandler X-Git-Tag: rel_2_0_37~30 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=32652c1980bb10c46ec09971a8c0d7786c117889;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git use VARCHAR for CLOB outputtypehandler Fixed issue in oracledb / cx_oracle dialects where output type handlers for ``CLOB`` were being routed to ``NVARCHAR`` rather than ``VARCHAR``, causing a double conversion to take place. Fixes: #12150 Change-Id: I9f55e9bc595997b873c831b0422f5af10dcc15ef (cherry picked from commit 5ded16fae8abfc31d43430cb25757fb434c37ba2) --- diff --git a/doc/build/changelog/unreleased_20/12150.rst b/doc/build/changelog/unreleased_20/12150.rst new file mode 100644 index 0000000000..a40e4623f2 --- /dev/null +++ b/doc/build/changelog/unreleased_20/12150.rst @@ -0,0 +1,8 @@ +.. change:: + :tags: bug, oracle + :tickets: 12150 + + Fixed issue in oracledb / cx_oracle dialects where output type handlers for + ``CLOB`` were being routed to ``NVARCHAR`` rather than ``VARCHAR``, causing + a double conversion to take place. + diff --git a/lib/sqlalchemy/dialects/oracle/cx_oracle.py b/lib/sqlalchemy/dialects/oracle/cx_oracle.py index 9b66d7ea78..6a2588883b 100644 --- a/lib/sqlalchemy/dialects/oracle/cx_oracle.py +++ b/lib/sqlalchemy/dialects/oracle/cx_oracle.py @@ -1353,8 +1353,13 @@ class OracleDialect_cx_oracle(OracleDialect): cx_Oracle.CLOB, cx_Oracle.NCLOB, ): + typ = ( + cx_Oracle.DB_TYPE_VARCHAR + if default_type is cx_Oracle.CLOB + else cx_Oracle.DB_TYPE_NVARCHAR + ) return cursor.var( - cx_Oracle.DB_TYPE_NVARCHAR, + typ, _CX_ORACLE_MAGIC_LOB_SIZE, cursor.arraysize, **dialect._cursor_var_unicode_kwargs,