From c3ad6da0c4a441d8d76376af29df3a18faba4361 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Thu, 11 Aug 2016 12:03:38 -0400 Subject: [PATCH] - add another example for chained polymorphic eager loading Change-Id: I87918ab4cd294d4b4a87a377c7b6b21105f4fd55 (cherry picked from commit 68b6984912760bfe4d9270750d8f39b9036b65b5) --- doc/build/orm/inheritance.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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:: -- 2.47.2