]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- add another example for chained polymorphic eager loading
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 11 Aug 2016 16:03:38 +0000 (12:03 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 11 Aug 2016 16:04:05 +0000 (12:04 -0400)
Change-Id: I87918ab4cd294d4b4a87a377c7b6b21105f4fd55
(cherry picked from commit 68b6984912760bfe4d9270750d8f39b9036b65b5)

doc/build/orm/inheritance.rst

index fb4de7df3be92e9db761bbae977facb2dc329753..5b3e2c39296b1a56f63944137856f4644e50827c 100644 (file)
@@ -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::