]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Adjust use_mapper_path rule for poly subclasses
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 13 Jan 2020 18:50:38 +0000 (13:50 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 20 Jan 2020 19:02:44 +0000 (14:02 -0500)
commit172de113f88a8129393f2efdc81452bf65af65cc
tree36673c07da2cc426229a833a1549fe25d0f66c7f
parent6f495d8a5f79afb316954cc8134035b04ec75afc
Adjust use_mapper_path rule for poly subclasses

We must change the approach from 2734439 as the information
loss is breaking subquery eager loading.

Move the adjustment into a deeper set of logic inside
of path_regsitry.  We can distinguish between a path
that will "naturally" build from an aliased entity
at the base, vs. one that will "naturally" build
on all raw mappers, based on if when we observe that
we are being given a with_polymorphic(), if the existing
parent path is already in progress or not.

In general, we prefer paths to have as much of the original
information as possible, and the "natural path" is supposed
to be where the loader lookup stuff happens.

Fixes: #5082
Change-Id: I3c0ee72993bae8a6f067bdef3dc9a57d83f64950
(cherry picked from commit 7cc2de880b0de2b127a54910761f357f3753c689)
lib/sqlalchemy/orm/path_registry.py
lib/sqlalchemy/orm/util.py
test/orm/inheritance/_poly_fixtures.py
test/orm/inheritance/test_polymorphic_rel.py
test/orm/test_utils.py