diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2016-08-11 12:03:38 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2016-08-11 12:04:05 -0400 |
commit | c3ad6da0c4a441d8d76376af29df3a18faba4361 (patch) | |
tree | 6e82e014b9396f95de6d41fb182be3f4c9234956 | |
parent | 09cf0376524dc0bac6c1ab05d3c43cdd29c362b1 (diff) | |
download | sqlalchemy-c3ad6da0c4a441d8d76376af29df3a18faba4361.tar.gz |
- add another example for chained polymorphic eager loading
Change-Id: I87918ab4cd294d4b4a87a377c7b6b21105f4fd55
(cherry picked from commit 68b6984912760bfe4d9270750d8f39b9036b65b5)
-rw-r--r-- | doc/build/orm/inheritance.rst | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/doc/build/orm/inheritance.rst b/doc/build/orm/inheritance.rst index fb4de7df3..5b3e2c392 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:: |