]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Establish that contains_eager()->alias can be replaced by of_type
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 14 Jan 2020 22:32:12 +0000 (17:32 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 15 Jan 2020 19:36:17 +0000 (14:36 -0500)
commitd4ede5fcea14709397ee3c45794636f5a37ceb27
treea11d837ed0fa2cb10aa5e4e6ed58469fefb4319c
parent6f495d8a5f79afb316954cc8134035b04ec75afc
Establish that contains_eager()->alias can be replaced by of_type

One test in test_of_type was creating a cartesian product
because contains_eager() was used with "alias" to refer
to a with_polymorphic(), but the wp was not used with of_type(),
so the pathing did not know that additional entities were present.

while the docs indicate that of_type() should be used, there is no
reason to use "alias" when you are using of_type().   Attempts
to make this automatic don't work as the current usage contract
with "alias" is that the contains_eager() chain can continue
along in terms of the base entities, which is another example
of the implicit swapping of entities for an aliased version of
themselves that really should be entirely marked as deprecated
throughout 1.4 and removed in 2.0.

So instead, add test coverage for the of_type() versions of
things and begin to make the case that we can remove "alias"
entirely, where previously we thought we would only deprecate
the string form.

For the 1.3 backport we are also picking a little bit of the
lambda combinations improvements that landed in 217948f5c7 and for
some reason were not backported.

Fixes: #5096
Change-Id: Ia7b021c4044332ab3282267815f208da64410e95
(cherry picked from commit b54b6ff7c09d15cedec3d65b10cd383ef41f1fbc)
lib/sqlalchemy/orm/interfaces.py
lib/sqlalchemy/orm/strategy_options.py
lib/sqlalchemy/testing/util.py
test/orm/inheritance/_poly_fixtures.py
test/orm/test_eager_relations.py
test/orm/test_froms.py
test/orm/test_of_type.py