manager_and_engineer = with_polymorphic(
Employee, [Manager, Engineer],
- aliased=True)
+ flat=True)
session.query(Company).\
options(
)
)
-.. versionadded:: 0.8
- :func:`.joinedload`, :func:`.subqueryload`, :func:`.contains_eager`
- and related loader options support
- paths that are qualified with
- :func:`~sqlalchemy.orm.interfaces.PropComparator.of_type`, supporting
- single target types as well as :func:`.orm.with_polymorphic` targets.
-
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::
as well as the ``_all()`` functions will remain available for backwards-
compatibility indefinitely.
+Polymorphic Eager Loading
+-------------------------
+
+Specification of polymorpic options on a per-eager-load basis is supported.
+See the section :ref:`eagerloading_polymorphic_subtypes` for examples
+of the :meth:`.PropComparator.of_type` method in conjunction with the
+:func:`.orm.with_polymorphic` function.
+
Default Loading Strategies
--------------------------
versions of MySQL.
:param flat: Boolean, will be passed through to the
- :meth:`.FromClause.alias` call so that aliases of :class:`.Join`
- objects don't include an enclosing SELECT. This can lead to more
- efficient queries in many circumstances. A JOIN against a nested JOIN
- will be rewritten as a JOIN against an aliased SELECT subquery on
- backends that don't support this syntax.
+ :meth:`.FromClause.alias` call so that aliases of :class:`.Join`
+ objects don't include an enclosing SELECT. This can lead to more
+ efficient queries in many circumstances. A JOIN against a nested JOIN
+ will be rewritten as a JOIN against an aliased SELECT subquery on
+ backends that don't support this syntax.
Setting ``flat`` to ``True`` implies the ``aliased`` flag is
also ``True``.