]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Use NCHAR + setinputsizes() for all NVARCHAR2
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 16 Jan 2018 17:41:29 +0000 (12:41 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 17 Jan 2018 14:29:32 +0000 (09:29 -0500)
The cx_Oracle dialect now calls setinputsizes() with cx_Oracle.NCHAR
unconditionally when the NVARCHAR2 datatype, in SQLAlchemy corresponding
to sqltypes.Unicode(), is in use.  Per cx_Oracle's author this allows
the correct conversions to occur within the Oracle client regardless
of the setting for NLS_NCHAR_CHARACTERSET.

Change-Id: I3989b7aaf2178c263015a7433939196b76baf1e4
Fixes: #4163
doc/build/changelog/unreleased_12/4163.rst [new file with mode: 0644]
lib/sqlalchemy/dialects/oracle/cx_oracle.py

diff --git a/doc/build/changelog/unreleased_12/4163.rst b/doc/build/changelog/unreleased_12/4163.rst
new file mode 100644 (file)
index 0000000..fad9bc7
--- /dev/null
@@ -0,0 +1,9 @@
+.. change::
+    :tags: bug, oracle
+    :tickets: 4163
+
+    The cx_Oracle dialect now calls setinputsizes() with cx_Oracle.NCHAR
+    unconditionally when the NVARCHAR2 datatype, in SQLAlchemy corresponding
+    to sqltypes.Unicode(), is in use.  Per cx_Oracle's author this allows
+    the correct conversions to occur within the Oracle client regardless
+    of the setting for NLS_NCHAR_CHARACTERSET.
index bf333ee95873aa652fba6d6ccd73a51e822cb0f9..24655ee1b19f37f1396ad43bbc2513fccdeec219 100644 (file)
@@ -1,4 +1,3 @@
-# oracle/cx_oracle.py
 # Copyright (C) 2005-2018 the SQLAlchemy authors and contributors
 # <see AUTHORS file>
 #
@@ -318,7 +317,7 @@ class _OracleChar(sqltypes.CHAR):
 
 class _OracleNVarChar(sqltypes.NVARCHAR):
     def get_dbapi_type(self, dbapi):
-        return getattr(dbapi, 'UNICODE', dbapi.STRING)
+        return dbapi.NCHAR
 
 
 class _OracleText(sqltypes.Text):
@@ -623,6 +622,7 @@ class OracleDialect_cx_oracle(OracleDialect):
 
             self._include_setinputsizes = {
                 cx_Oracle.NCLOB, cx_Oracle.CLOB, cx_Oracle.LOB,
+                cx_Oracle.NCHAR, cx_Oracle.FIXED_NCHAR,
                 cx_Oracle.BLOB, cx_Oracle.FIXED_CHAR, cx_Oracle.TIMESTAMP
             }