On Saturday, March 2, 2019 at 10:27:52 AM UTC-8, Kenaniah Cerny wrote: > > Hi Jeremy (et al.), > > I have some code that I would like to contribute back upstream that allows > for associations to be created `:through` other associations, even > recursively. This concept would allow, for example, the following: > > Artist.many_to_many :albums > Album.many_to_many :tags > Artist.many_to_many :tags, through: :albums > > > User.one_to_many :user_has_security_groups > User.many_to_many :security_groups, through: :user_has_security_groups > User.many_to_many :privileges, through: :security_groups > > > I'm still working on cleaning up and generalizing a few parts (porting > over tests, removing activesupport deps, adding docs, including the proper > plugins, etc.), but I wanted to ask for some initial feedback before > getting too deep into the weeds. Still a ton of work to be done, but an > initial gut-check on whether this could be a candidate for merging down the > road would be helpful. > > The initial diff can be found here: > https://github.com/jeremyevans/sequel/compare/master...spidrtech:through-assoc?expand=1&w=1 >
This is the approach ActiveRecord took, and is something I purposely avoided due to the complexity. You can handle all of these types of associations using the many_through_many plugin, you just need to be more explicit about it. What you have there is a good start, but when you try to support all of the association options on the through associations, I think you'll find the complexity gets too high and/or you can only support a subset of association (the simple cases). One example, what if the through association and the current association both have an association block? So, I don't think this is a good candidate for inclusion with Sequel. However, if you would like to continue working on it and plan to support it, you should be able to implement it as an external plugin, and I can link to it from the Sequel website. 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.
