From f848140083c316b81456c8c3426ad3fd04caf6fa Mon Sep 17 00:00:00 2001 From: Gord Thompson Date: Sat, 25 Jun 2022 10:34:51 -0600 Subject: Change setinputsizes behavior for mssql+pyodbc The ``use_setinputsizes`` parameter for the ``mssql+pyodbc`` dialect now defaults to ``True``; this is so that non-unicode string comparisons are bound by pyodbc to pyodbc.SQL_VARCHAR rather than pyodbc.SQL_WVARCHAR, allowing indexes against VARCHAR columns to take effect. In order for the ``fast_executemany=True`` parameter to continue functioning, the ``use_setinputsizes`` mode now skips the ``cursor.setinputsizes()`` call specifically when ``fast_executemany`` is True and the specific method in use is ``cursor.executemany()``, which doesn't support setinputsizes. The change also adds appropriate pyodbc DBAPI typing to values that are typed as :class:`_types.Unicode` or :class:`_types.UnicodeText`, as well as altered the base :class:`_types.JSON` datatype to consider JSON string values as :class:`_types.Unicode` rather than :class:`_types.String`. Fixes: #8177 Change-Id: I6c8886663254ae55cf904ad256c906e8f5e11f48 --- lib/sqlalchemy/sql/sqltypes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/sqlalchemy/sql') diff --git a/lib/sqlalchemy/sql/sqltypes.py b/lib/sqlalchemy/sql/sqltypes.py index 6adc6ca77..c67614070 100644 --- a/lib/sqlalchemy/sql/sqltypes.py +++ b/lib/sqlalchemy/sql/sqltypes.py @@ -2482,7 +2482,7 @@ class JSON(Indexable, TypeEngine[Any]): .. versionadded:: 1.3.11 """ - return self._binary_w_type(String(), "as_string") + return self._binary_w_type(Unicode(), "as_string") def as_integer(self): """Cast an indexed value as integer. -- cgit v1.2.1