summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/relationships.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2014-02-28 14:15:13 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2014-02-28 14:15:13 -0500
commit12ce2edc92eff647fedfd6943d60703b3c3eeff5 (patch)
tree1b2dec2a070c2df0b23bb38b8b1e9e0c552fd266 /lib/sqlalchemy/orm/relationships.py
parente21cd0d95fb6cdcb4e10ea78abd5626bb92c37c3 (diff)
downloadsqlalchemy-12ce2edc92eff647fedfd6943d60703b3c3eeff5.tar.gz
- Added a new option to :paramref:`.relationship.innerjoin` which is
to specify the string ``"nested"``. When set to ``"nested"`` as opposed to ``True``, the "chaining" of joins will parenthesize the inner join on the right side of an existing outer join, instead of chaining as a string of outer joins. This possibly should have been the default behavior when 0.9 was released, as we introduced the feature of right-nested joins in the ORM, however we are keeping it as a non-default for now to avoid further surprises. fixes #2976
Diffstat (limited to 'lib/sqlalchemy/orm/relationships.py')
-rw-r--r--lib/sqlalchemy/orm/relationships.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/sqlalchemy/orm/relationships.py b/lib/sqlalchemy/orm/relationships.py
index 43db14e13..f0e3076ad 100644
--- a/lib/sqlalchemy/orm/relationships.py
+++ b/lib/sqlalchemy/orm/relationships.py
@@ -488,11 +488,22 @@ class RelationshipProperty(StrategizedProperty):
or when the reference is one-to-one or a collection that is guaranteed
to have one or at least one entry.
+ If the joined-eager load is chained onto an existing LEFT OUTER JOIN,
+ ``innerjoin=True`` will be bypassed and the join will continue to
+ chain as LEFT OUTER JOIN so that the results don't change. As an alternative,
+ specify the value ``"nested"``. This will instead nest the join
+ on the right side, e.g. using the form "a LEFT OUTER JOIN (b JOIN c)".
+
+ .. versionadded:: 0.9.4 Added ``innerjoin="nested"`` option to support
+ nesting of eager "inner" joins.
+
.. seealso::
:ref:`what_kind_of_loading` - Discussion of some details of
various loader options.
+ :parmref:`.joinedload.innerjoin` - loader option version
+
:param join_depth:
when non-``None``, an integer value indicating how many levels
deep "eager" loaders should join on a self-referring or cyclical
@@ -522,8 +533,8 @@ class RelationshipProperty(StrategizedProperty):
* ``joined`` - items should be loaded "eagerly" in the same query as
that of the parent, using a JOIN or LEFT OUTER JOIN. Whether
- the join is "outer" or not is determined by the ``innerjoin``
- parameter.
+ the join is "outer" or not is determined by the
+ :paramref:`~.relationship.innerjoin` parameter.
* ``subquery`` - items should be loaded "eagerly" as the parents are
loaded, using one additional SQL statement, which issues a JOIN to a