]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
mssql: fall back to base type for alias types during reflection
authorCarlos Serrano <caseov@gmail.com>
Wed, 18 Mar 2026 15:37:08 +0000 (11:37 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 20 Mar 2026 19:29:24 +0000 (15:29 -0400)
commit77330eb79a36ad221e17352d1b7a72e771dde621
tree2f9d766608616f571047efc3b23fc775f16b38bd
parented354e1c303b2ab746ba7b811615ce888f2e8a72
mssql: fall back to base type for alias types during reflection

Fixed regression from version 2.0.42 caused by :ticket:`12654` where the
updated column reflection query would receive SQL Server "type alias" names
for special types such as ``sysname``, whereas previously the base name
would be received (e.g. ``nvarchar`` for ``sysname``), leading to warnings
that such types could not be reflected and resulting in :class:`.NullType`,
rather than the expected :class:`.NVARCHAR` for a type like ``sysname``.
The column reflection query now joins ``sys.types`` a second time to look
up the base type when the user type name is not present in
:attr:`.MSDialect.ischema_names`, and both names are checked in
:attr:`.MSDialect.ischema_names` for a match. Pull request courtesy Carlos
Serrano.

Fixes: #13181
Fixes: #13182
Closes: #13178
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/13178
Pull-request-sha: be5c3850594665c0154ae215d4f9c322cc5a3f5a

Change-Id: I7fe86b80dfa45b208f7d97003ee5b1df3f07bfe7
(cherry picked from commit 1c78168f8a1a9cd3c88f1977bba1bac763225482)
doc/build/changelog/unreleased_20/13181.rst [new file with mode: 0644]
lib/sqlalchemy/dialects/mssql/base.py
test/dialect/mssql/test_reflection.py