]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Change setinputsizes behavior for mssql+pyodbc
authorGord Thompson <gord@gordthompson.com>
Sat, 25 Jun 2022 16:34:51 +0000 (10:34 -0600)
committermike bayer <mike_mp@zzzcomputing.com>
Wed, 29 Jun 2022 13:02:39 +0000 (13:02 +0000)
commitf848140083c316b81456c8c3426ad3fd04caf6fa
tree53baf5ee691e6a559e60d5c0d86136b01213f653
parent6a560cf03c302d2ebd9ae7c7dc4d587983096ba4
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
doc/build/changelog/unreleased_20/8177.rst [new file with mode: 0644]
lib/sqlalchemy/connectors/pyodbc.py
lib/sqlalchemy/dialects/mssql/pyodbc.py
lib/sqlalchemy/sql/sqltypes.py
test/dialect/mssql/test_engine.py