]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- document that joinedload/eagerload work with of_type() + with_polymoprhic()
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 23 Apr 2014 23:13:04 +0000 (19:13 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 23 Apr 2014 23:13:24 +0000 (19:13 -0400)
doc/build/orm/inheritance.rst

index bf9895065fa40cad8a2cda39b1fa2536219abf26..d68228259c7e2939111385e11b4786e9dbb02c94 100644 (file)
@@ -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`.
@@ -481,10 +481,26 @@ objects, querying the ``employee`` and ``engineer`` tables simultaneously::
         options(subqueryload_all(Company.employees.of_type(Engineer),
                         Engineer.machines))
 
+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
 ------------------------