From: Mike Bayer Date: Wed, 23 Apr 2014 23:13:04 +0000 (-0400) Subject: - document that joinedload/eagerload work with of_type() + with_polymoprhic() X-Git-Tag: rel_0_8_7~37 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6b23eb0f54f048154b6a9f97896cb4a16d916fc4;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - document that joinedload/eagerload work with of_type() + with_polymoprhic() --- diff --git a/doc/build/orm/inheritance.rst b/doc/build/orm/inheritance.rst index bf9895065f..d68228259c 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`. @@ -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 ------------------------