]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
use sys.columns to allow accurate joining to other SYS tables
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 8 Jun 2025 17:01:45 +0000 (13:01 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 10 Jun 2025 13:07:30 +0000 (09:07 -0400)
commitc868afc090dde3ce5beac5cd3d6776567e9cf845
treeef721ef191daa8fff5092f64c490c571f7a26a54
parentf2eda87a6b7f1534851da2d0370bd034d1791bfc
use sys.columns to allow accurate joining to other SYS tables

Reworked SQL Server column reflection to be based on the ``sys.columns``
table rather than ``information_schema.columns`` view.  By correctly using
the SQL Server ``object_id()`` function as a lead and joining to related
tables on object_id rather than names, this repairs a variety of issues in
SQL Server reflection, including:

* Issue where reflected column comments would not correctly line up
with the columns themselves in the case that the table had been ALTERed
* Correctly targets tables with awkward names such as names with brackets,
when reflecting not just the basic table / columns but also extended
information including IDENTITY, computed columns, comments which
did not work previously
* Correctly targets IDENTITY, computed status from temporary tables
which did not work previously

Fixes: #12654
Change-Id: I3bf3088c3eec8d7d3d2abc9da35f9628ef78d537
doc/build/changelog/unreleased_20/12654.rst [new file with mode: 0644]
lib/sqlalchemy/dialects/mssql/base.py
lib/sqlalchemy/dialects/mssql/information_schema.py
lib/sqlalchemy/testing/requirements.py
lib/sqlalchemy/testing/suite/test_reflection.py
test/dialect/mssql/test_reflection.py
test/requirements.py