]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Use coercion rules for aliased() against select/union constructs
authorRens Groothuijsen <l.groothuijsen@alumni.maastrichtuniversity.nl>
Thu, 16 Jul 2026 00:03:25 +0000 (20:03 -0400)
committerMichael Bayer <mike_mp@zzzcomputing.com>
Thu, 16 Jul 2026 02:03:00 +0000 (02:03 +0000)
commit06c8bae6ad1156b5748e370953bea55eb0168333
tree2a4edd23d615c26d5beaa165359dfe271c95ed44
parente33d9f4375547552835f44061562b6976b616d6d
Use coercion rules for aliased() against select/union constructs

Calling :func:`_orm.aliased` against a :func:`_sql.select` or
:func:`_sql.union` / :class:`_sql.CompoundSelect` construct, which
previously failed with an obscure ``AttributeError`` regarding a missing
``.mapper`` attribute, now raises when using SQLAlchemy 2.1, and emits a
deprecation warning under SQLAlchemy 2.0 as it coerces the construct into a
subquery instead.  This matches the behavior of other similar implicit
SELECT-to-FROM coercions.  Pull request courtesy Rens Groothuijsen.

Fixes: #6274
Closes: #12433
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12433
Pull-request-sha: 416dde8509ac05b209400603d9e00bc82aa47c79

Change-Id: I63bdec71074b81fb85bf29e6ca0dd81cbe3f8cb3
(cherry picked from commit 16177b8c73e492e5adaad8f51095f9981831da41)
doc/build/changelog/unreleased_20/6274.rst [new file with mode: 0644]
lib/sqlalchemy/orm/util.py
test/orm/test_deprecations.py
test/orm/test_utils.py