Today I learned that Sequel supports filtering by associations, for both many-to-one and one-to-many relationships. This means that I can rewrite
Artist.where(:id=>Album.where(:released).select(:artist_id)) without repeating the foreign key: Artist.where(:albums=>Album.where(:released)) That's really nice. On Monday, September 17, 2018 at 12:27:49 AM UTC+2, Janko Marohnić wrote: > > Nice, I didn't know about the dataset_associations plugin! That's a really > convenient way to automatize IN subqueries, it's going to reduce a lot of > our boilerplate. > > Ok, now I definitely feel like I have everything I need. Thanks a lot! > > Kind regards, > Janko > > On Sun, Sep 16, 2018 at 10:53 PM Jeremy Evans <[email protected]> > wrote: > >> On Sunday, September 16, 2018 at 12:42:42 PM UTC-7, Janko Marohnić wrote: >>> >>> Wow, the COUNT approach is *really* inefficient compared to the IN >>> subquery, it totally makes sense never to use it :P >>> >>> Would you perhaps be open to adding a >>> `Sequel::Model.association_dataset` method some time in the future that >>> would retrieve the `eager_loading_dataset` (called with >>> `.association_dataset(:association)`)? I think it would be nice >>> alternative, as it would allow one to avoid duplicating any conditions and >>> ordering configured for the association. >>> >> >> I'm not sure. I would have to think about it. >> >> There is the dataset_associations plugin, which is designed to provide >> association methods on class's dataset that return a dataset of associated >> objects. That's probably going to more usable for most people, though it >> could be less efficient. >> >> Thanks, >> Jeremy >> >> -- >> You received this message because you are subscribed to a topic in the >> Google Groups "sequel-talk" group. >> To unsubscribe from this topic, visit >> https://groups.google.com/d/topic/sequel-talk/Na7HQji-Y_k/unsubscribe. >> To unsubscribe from this group and all its topics, 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. >> > -- 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.
