On Saturday, August 26, 2017 at 8:35:29 PM UTC-7, Aryk Grosz wrote: > > Hi Jeremy, > > I was looking through the code: > > > https://github.com/jeremyevans/sequel/blob/master/lib/sequel/plugins/dataset_associations.rb#L94 > > It seems like any special conditions put on the association are largely > ignored. For example, if there is a :graph_block which would normally get > used on association_join, the #associated call does not use any of it, even > with the :dataset_associations_join block that was added at the bottom. > > I would expect associated to honor the conditions in the join. Is there a > reason why we can't use them? For example, here > <https://github.com/jeremyevans/sequel/blob/master/lib/sequel/plugins/dataset_associations.rb#L137> > it > ignores join conditions that would otherwise be getting used on > associations_join. >
Dataset associations in general supports options supported with normal loading and eager loading, not eager_graph loading and association_join. So it uses the association block as well as the :conditions option, not :graph_block and :graph_conditions. It's not possible to support both types of options at the same time. Check the dataset_associations plugin specs for how the :conditions option and association block are used for filtering. Considering how dataset_associations works (using subqueries, not joins), I wouldn't expect it to use graph/join specific options for that part. Now, if :dataset_associations_join is used, it may be possible (I'm not sure) to use the eager_graph specific options for the join, but as it would break backwards compatibility, we'd probably need to use a new option/value to enable it (e.g. :dataset_associations_join=>:graph). I'll consider a pull request that adds such support, if it supports all association types that ship with Sequel and includes updates to both the plugin specs and integration tests. The current dataset_associations documentation sort of assumes that eager loading means via eager and not eager_graph. I'll also consider a documentation pull request that makes the current behavior more clear. Thanks, Jeremy -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/sequel-talk. For more options, visit https://groups.google.com/d/optout.
