summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2019-10-14 21:53:44 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2019-10-15 11:57:19 -0400
commite4a5da1c5a4ed038c1c28f236e2e963b27554549 (patch)
tree33c4407fcf735412959c8b657a035848bc88013e /lib/sqlalchemy
parent567ee8d6a90a150e5079fc6d1cdad2734172e2e7 (diff)
downloadsqlalchemy-e4a5da1c5a4ed038c1c28f236e2e963b27554549.tar.gz
Use cx_Oracle.FIXED_NCHAR for sqltypes.NCHAR
The :class:`.sqltypes.NCHAR` datatype will now bind to the ``cx_Oracle.FIXED_NCHAR`` DBAPI data bindings when used in a bound parameter, which supplies proper comparison behavior against a variable-length string. Previously, the :class:`.sqltypes.NCHAR` datatype would bind to ``cx_oracle.NCHAR`` which is not fixed length; the :class:`.sqltypes.CHAR` datatype already binds to ``cx_Oracle.FIXED_CHAR`` so it is now consistent that :class:`.sqltypes.NCHAR` binds to ``cx_Oracle.FIXED_NCHAR``. Fixes: #4913 Change-Id: I5bb111f2e06bbdd525bc5f716579baad31bbb3db
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/dialects/oracle/cx_oracle.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/sqlalchemy/dialects/oracle/cx_oracle.py b/lib/sqlalchemy/dialects/oracle/cx_oracle.py
index 2f37b43a1..2572a79b3 100644
--- a/lib/sqlalchemy/dialects/oracle/cx_oracle.py
+++ b/lib/sqlalchemy/dialects/oracle/cx_oracle.py
@@ -429,11 +429,18 @@ class _OracleDate(sqltypes.Date):
return process
+# TODO: the names used across CHAR / VARCHAR / NCHAR / NVARCHAR
+# here are inconsistent and not very good
class _OracleChar(sqltypes.CHAR):
def get_dbapi_type(self, dbapi):
return dbapi.FIXED_CHAR
+class _OracleNChar(sqltypes.NCHAR):
+ def get_dbapi_type(self, dbapi):
+ return dbapi.FIXED_NCHAR
+
+
class _OracleUnicodeStringNCHAR(oracle.NVARCHAR2):
def get_dbapi_type(self, dbapi):
return dbapi.NCHAR
@@ -722,12 +729,12 @@ class OracleDialect_cx_oracle(OracleDialect):
sqltypes.String: _OracleString,
sqltypes.UnicodeText: _OracleUnicodeTextCLOB,
sqltypes.CHAR: _OracleChar,
+ sqltypes.NCHAR: _OracleNChar,
sqltypes.Enum: _OracleEnum,
oracle.LONG: _OracleLong,
oracle.RAW: _OracleRaw,
sqltypes.Unicode: _OracleUnicodeStringCHAR,
sqltypes.NVARCHAR: _OracleUnicodeStringNCHAR,
- sqltypes.NCHAR: _OracleUnicodeStringNCHAR,
oracle.NCLOB: _OracleUnicodeTextNCLOB,
oracle.ROWID: _OracleRowid,
}