I like to share dataset concerns (conditions, order) across models by 
passing a block to the association. This should be of no surprise to 
anybody:

  one_to_many :widgets do |ds|
    ds.sellable
  end

What may come as a surprise is that the block is ignored when the 
association is being graphed through `eager_graph` or `association_join`. 
Separate options to the association are needed if you end up in this 
scenario (AFAIK). In the below example, the `JOIN` on `widgets` in the 
resulting SQL doesn’t state the sellable conditions.

   Model.association_join(:widgets)

This can be worked around a few different ways, but I’m curious if anybody 
else is encountering this on their teams, and how you may have worked 
around it? It's documented that this occurs, so I'm not sure more 
documentation would help.

I’d think I'd almost rather there be an exception raised here, or at least 
an option/plugin to, forcing me to allow the `eager_graph` or 
`association_join` to continue, knowing the conditions are lost without 
also setting `graph_block` or similar options on the association.

Thoughts?


Adam

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/d947a3e0-6672-416d-8096-106dec8747c2n%40googlegroups.com.

Reply via email to