On Aug 29, 2012, at 7:00 PM, Christopher Lee wrote:
>
>
> There is no endless recursion going on; each object is only loaded
> once. Sorry I was not specific. But, given the following object
> graph:
>
> Foo 1 -> [Bar 1, Bar 2, Bar 3]
> Foo 2 -> [Bar 4, Bar 5, Bar 6]
> Bar 1 -> [Foo 1, Foo 2]
>
> When I query for Foo1, I want to eagerly load Foo1, Bar 1, Bar 2, and
> Bar3. I do not want to eagerly load Bar 1, Foo 2, Bar 4, Bar 5, Bar
> 6.
> Similarly, if I query for Bar 1, I want to eagerly load Foo1 and Foo2.
> I do not want to eagerly load Bar 2-6.
>
> Is that any clearer?
sure, join_depth will control how deep a particular joined/subquery eagerload chain will go. Current behavior of join_depth is a simple check of how deep a particular relationship is located in an eager load chain, and this is not specific to the target relationship in contradiction to my earlier post where I was remembering incorrectly what it does. Setting it to one on both of these relationships will cause the eager chain to only go one mapper deep.
This raises the issue of join_depth preventing eager loads entirely when the parent object is itself already the subject of unrelated eager load, which isn't quite what it was intended for (it was intended for recursive loops), so I wonder if a new feature might someday be warranted which allows the "depth" question to be answered in a more comprehensive way.