On Mon, Sep 13, 2021 at 12:43 PM [email protected] <
[email protected]> wrote:

> 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
>

Sorry for not responding to this earlier.  For some reason it ended up in
my spam folder.

I think it may be possible to add a plugin that automatically sets
`allow_eager_graph: false` for associations with blocks but without one of
the :graph_* options.  I agree with you that that behavior may be a better
default. Maybe I could consider making it the default in Sequel 6.

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 view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/CADGZSScuV_%2BcBeS2BB9kz%3DuOUsSJvn%2BndKs2DCoEgo4vnYcPgQ%40mail.gmail.com.

Reply via email to