]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Set complete FROM list for subquery eagerload's orig query
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 15 Jun 2017 17:12:16 +0000 (13:12 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 15 Jun 2017 22:52:26 +0000 (18:52 -0400)
commitd2131156de654de697e14e4f1fb993c22dca2287
tree5e97fb0da7642a95e803998964592adeef5e0ef3
parentfa62a0af2706475ff3bef246fc02b2968cb4c03c
Set complete FROM list for subquery eagerload's orig query

Instead of checking that the "orig_entity" we receive applies
as a correct FROM element for the subquery we're building,
set the FROM clause of the query to exactly what it already
is based on column_descriptions (assuming there is no FROM
list already), thereby ensuring that the FROM list will remain
intact, regardless of what orig_entity turns out to be and
what the target_cols ultimately refer towards.

Fixed issue with subquery eagerloading which continues on from
the series of issues fixed in :ticket:`2699`, :ticket:`3106`,
:ticket:`3893` involving that the "subquery" contains the correct
FROM clause when beginning from a joined inheritance subclass
and then subquery eager loading onto a relationship from
the base class, while the query also includes criteria against
the subclass. The fix in the previous tickets did not accommodate
for additional subqueryload operations loading more deeply from
the first level, so the fix has been further generalized.

Change-Id: Ic909590814f71e577d8266b1dbc4c393dc48e019
Fixes: #4011
(cherry picked from commit 6d2a03c1ec21cc428c91476c170ad7dbe219926c)
doc/build/changelog/changelog_11.rst
lib/sqlalchemy/orm/strategies.py
test/orm/inheritance/_poly_fixtures.py
test/orm/test_subquery_relations.py