summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2014-04-23 19:13:04 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2014-04-23 19:13:04 -0400
commit5016b581b6a0099b5d4babf885ae1f2c05a9589f (patch)
treef6e81e6bf9d6a6a6e792dc6a4b0204319bd626f7
parent18403c07f94fdfbd15985ec7f72e5892976e56f4 (diff)
downloadsqlalchemy-5016b581b6a0099b5d4babf885ae1f2c05a9589f.tar.gz
- document that joinedload/eagerload work with of_type() + with_polymoprhic()
-rw-r--r--doc/build/orm/inheritance.rst22
1 files changed, 19 insertions, 3 deletions
diff --git a/doc/build/orm/inheritance.rst b/doc/build/orm/inheritance.rst
index 9e30848bf..623892b33 100644
--- a/doc/build/orm/inheritance.rst
+++ b/doc/build/orm/inheritance.rst
@@ -469,8 +469,8 @@ subselect back to the parent ``companies`` table.
:func:`.orm.aliased` and :func:`.orm.with_polymorphic` constructs in conjunction
with :meth:`.Query.join`, ``any()`` and ``has()``.
-Eager Loading of Specific Subtypes
-++++++++++++++++++++++++++++++++++
+Eager Loading of Specific or Polymorphic Subtypes
+++++++++++++++++++++++++++++++++++++++++++++++++++
The :func:`.joinedload` and :func:`.subqueryload` options also support
paths which make use of :func:`~sqlalchemy.orm.interfaces.PropComparator.of_type`.
@@ -484,10 +484,26 @@ objects, querying the ``employee`` and ``engineer`` tables simultaneously::
)
)
+As is the case with :meth:`.Query.join`, :func:`~sqlalchemy.orm.interfaces.PropComparator.of_type`
+also can be used with eager loading and :func:`.orm.with_polymorphic`
+at the same time, so that all sub-attributes of all referenced subtypes
+can be loaded::
+
+ manager_and_engineer = with_polymorphic(
+ Employee, [Manager, Engineer],
+ aliased=True)
+
+ session.query(Company).\
+ options(
+ joinedload(Company.employees.of_type(manager_and_engineer))
+ )
+ )
+
.. versionadded:: 0.8
:func:`.joinedload` and :func:`.subqueryload` support
paths that are qualified with
- :func:`~sqlalchemy.orm.interfaces.PropComparator.of_type`.
+ :func:`~sqlalchemy.orm.interfaces.PropComparator.of_type`, supporting
+ single target types as well as :func:`.orm.with_polymorphic` targets.
Single Table Inheritance
------------------------