From f83cbd50d7d0710f9bd174690cd2ef17f91122f3 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Fri, 28 Jul 2017 17:50:21 -0400 Subject: See what happens if we setinputsizes for String Per Anthony Tuininga, setinputsizes() is important particularly if you have a unicode value you want to line up with an index under Python 3, because you want the type to be bound using NVARCHAR2 and not VARCHAR2. Only if we setinputsizes() for NVARCHAR2 will we get that effect. So see at least if setinputsizes() works for STRING these days or otherwise figure out what the problem was. Additionally, the type object now for NVARCHAR2 is cx_Oracle.NCHAR, so use that, and also remove some old _cx_oracle_XYZ collections we aren't using to reduce verbosity. Change-Id: I4977f54796485ec454b20697ec20db6d70fb6f84 --- lib/sqlalchemy/dialects/oracle/cx_oracle.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'lib/sqlalchemy') diff --git a/lib/sqlalchemy/dialects/oracle/cx_oracle.py b/lib/sqlalchemy/dialects/oracle/cx_oracle.py index 4e9f6314b..038cb8846 100644 --- a/lib/sqlalchemy/dialects/oracle/cx_oracle.py +++ b/lib/sqlalchemy/dialects/oracle/cx_oracle.py @@ -50,8 +50,7 @@ on the URL, or as keyword arguments to :func:`.create_engine()` are: * ``exclude_setinputsizes`` - a tuple or list of string DBAPI type names to be excluded from the "auto setinputsizes" feature. The type names here must match DBAPI types that are found in the "cx_Oracle" module namespace, - such as cx_Oracle.UNICODE, cx_Oracle.NCLOB, etc. Defaults to - ``(STRING, UNICODE)``. + such as cx_Oracle.NCHAR, cx_Oracle.NCLOB, etc. Defaults to ``()``. .. versionadded:: 0.8 specific DBAPI types can be excluded from the auto_setinputsizes feature via the exclude_setinputsizes attribute. @@ -95,7 +94,7 @@ Python 2: the advantage that the unicode conversion is global to all statements at the cx_Oracle driver level, meaning it works with raw textual SQL statements that have no typing information associated. However, this system - has been observed to incur signfiicant performance overhead, not only + has been observed to incur significant performance overhead, not only because it takes effect for all string values unconditionally, but also because cx_Oracle under Python 2 seems to use a pure-Python function call in order to do the decode operation, which under cPython can orders of @@ -373,7 +372,7 @@ class _OracleChar(_NativeUnicodeMixin, sqltypes.CHAR): class _OracleNVarChar(_NativeUnicodeMixin, sqltypes.NVARCHAR): def get_dbapi_type(self, dbapi): - return getattr(dbapi, 'UNICODE', dbapi.STRING) + return dbapi.NCHAR class _OracleText(_LOBMixin, sqltypes.Text): @@ -496,9 +495,9 @@ class OracleExecutionContext_cx_oracle(OracleExecutionContext): del param[fromname] if self.dialect.auto_setinputsizes: - # cx_oracle really has issues when you setinputsizes - # on String, including that outparams/RETURNING - # breaks for varchars + # setinputsizes for all datatypes. + # previously, we had problems with String but these seem + # to not be present. self.set_input_sizes( quoted_bind_names, exclude_types=self.dialect.exclude_setinputsizes @@ -666,7 +665,7 @@ class OracleDialect_cx_oracle(OracleDialect): def __init__(self, auto_setinputsizes=True, - exclude_setinputsizes=("STRING", "UNICODE"), + exclude_setinputsizes=(), auto_convert_lobs=True, threaded=True, allow_twophase=True, @@ -696,9 +695,6 @@ class OracleDialect_cx_oracle(OracleDialect): ).difference([None]) self.exclude_setinputsizes = types(*(exclude_setinputsizes or ())) - self._cx_oracle_string_types = types("STRING", "UNICODE", - "NCLOB", "CLOB") - self._cx_oracle_unicode_types = types("UNICODE", "NCLOB") self._cx_oracle_binary_types = types("BFILE", "CLOB", "NCLOB", "BLOB") self.supports_unicode_binds = self.cx_oracle_ver >= (5, 0) @@ -720,7 +716,6 @@ class OracleDialect_cx_oracle(OracleDialect): if self.cx_oracle_ver is None: # this occurs in tests with mock DBAPIs - self._cx_oracle_string_types = set() self._cx_oracle_with_unicode = False elif util.py3k or ( self.cx_oracle_ver >= (5,) and -- cgit v1.2.1