From: Mike Bayer Date: Tue, 16 Jan 2018 17:41:29 +0000 (-0500) Subject: Use NCHAR + setinputsizes() for all NVARCHAR2 X-Git-Tag: rel_1_2_2~6^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ff4898fd42d0b6f5166b1c41a71adafd0d9fed40;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Use NCHAR + setinputsizes() for all NVARCHAR2 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 --- diff --git a/doc/build/changelog/unreleased_12/4163.rst b/doc/build/changelog/unreleased_12/4163.rst new file mode 100644 index 0000000000..fad9bc7f15 --- /dev/null +++ b/doc/build/changelog/unreleased_12/4163.rst @@ -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. diff --git a/lib/sqlalchemy/dialects/oracle/cx_oracle.py b/lib/sqlalchemy/dialects/oracle/cx_oracle.py index bf333ee958..24655ee1b1 100644 --- a/lib/sqlalchemy/dialects/oracle/cx_oracle.py +++ b/lib/sqlalchemy/dialects/oracle/cx_oracle.py @@ -1,4 +1,3 @@ -# oracle/cx_oracle.py # Copyright (C) 2005-2018 the SQLAlchemy authors and contributors # # @@ -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 }