]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
enhance double-aliased table logic to handle more cases
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 16 Jan 2022 15:21:45 +0000 (10:21 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 18 Jan 2022 21:07:41 +0000 (16:07 -0500)
commitbb11d5b7c2256861fdfe64f5cded94ce15266132
treee623a880409a28adef0211906df81fd2363d34e3
parenteb716884a4abcabae84a6aaba105568e925b7d27
enhance double-aliased table logic to handle more cases

Fixed ORM regression where calling the :func:`_orm.aliased` function
against an existing :func:`_orm.aliased` construct would fail to produce
correct SQL if the existing construct were against a fixed table. The fix
allows that the original :func:`_orm.aliased` construct is disregarded if
it were only against a table that's now being replaced. It also allows for
correct behavior when constructing a :func:`_orm.aliased` without a
selectable argument against a :func:`_orm.aliased` that's against a
subuquery, to create an alias of that subquery (i.e. to change its name).

The nesting behavior of :func:`_orm.aliased` remains in place for the case
where the outer :func:`_orm.aliased` object is against a subquery which in
turn refers to the inner :func:`_orm.aliased` object. This is a relatively
new 1.4 feature that helps to suit use cases that were previously served by
the deprecated ``Query.from_self()`` method.

Fixes: #7576
Change-Id: Ia9ca606f6300e38b6040eb6fc7facfe97c8cf057
doc/build/changelog/unreleased_14/7576.rst [new file with mode: 0644]
lib/sqlalchemy/orm/util.py
test/orm/test_froms.py