From: Mike Bayer Date: Thu, 11 Aug 2016 16:03:38 +0000 (-0400) Subject: - add another example for chained polymorphic eager loading X-Git-Tag: rel_1_1_0~54 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c3ad6da0c4a441d8d76376af29df3a18faba4361;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - add another example for chained polymorphic eager loading Change-Id: I87918ab4cd294d4b4a87a377c7b6b21105f4fd55 (cherry picked from commit 68b6984912760bfe4d9270750d8f39b9036b65b5) --- diff --git a/doc/build/orm/inheritance.rst b/doc/build/orm/inheritance.rst index fb4de7df3b..5b3e2c3929 100644 --- a/doc/build/orm/inheritance.rst +++ b/doc/build/orm/inheritance.rst @@ -508,6 +508,20 @@ can be loaded:: ) ) +Note that once :meth:`~PropComparator.of_type` is the target of the eager load, +that's the entity we would use for subsequent chaining, not the original class +or derived class. If we wanted to further eager load a collection on the +eager-loaded ``Engineer`` class, we access this class from the namespace of the +:func:`.orm.with_polymorphic` object:: + + session.query(Company).\ + options( + joinedload(Company.employees.of_type(manager_and_engineer)).\ + subqueryload(manager_and_engineer.Engineer.computers) + ) + ) + + Another option for the above query is to state the two subtypes separately; the :func:`.joinedload` directive should detect this and create the above ``with_polymorphic`` construct automatically::