]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
use VARCHAR for CLOB outputtypehandler
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 2 Dec 2024 23:59:19 +0000 (18:59 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 2 Dec 2024 23:59:55 +0000 (18:59 -0500)
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)

doc/build/changelog/unreleased_20/12150.rst [new file with mode: 0644]
lib/sqlalchemy/dialects/oracle/cx_oracle.py

diff --git a/doc/build/changelog/unreleased_20/12150.rst b/doc/build/changelog/unreleased_20/12150.rst
new file mode 100644 (file)
index 0000000..a40e462
--- /dev/null
@@ -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.
+
index 9b66d7ea783ebeec09a7c062c196f77b7da93a41..6a2588883b6fb8c076a50d94b7dc8299607f7ae8 100644 (file)
@@ -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,