That makes sense, I'm ok with this change. On Saturday, April 22, 2017 at 5:01:20 AM UTC+10, Jeremy Evans wrote: > > Currently, if you define an association such as: > > Foo.one_to_many :bars > > It adds the following methods to Foo instances: > > # read only methods > bars > bars_dataset > > # modification methods > add_bar > remove_bar > remove_all_bars > > For the majority of associations, users generally only call the read only > methods. There are certainly cases where users call the modification > methods, but I'm guessing less than half of associations actually use them. > > I'm considering deprecating the automatic addition of modification > methods, and making associations only define the read only methods by > default in Sequel 5. To enable the modification methods for a single > association, you could do: > > Foo.one_to_many :bars, :read_only=>false > > You could also do: > > Sequel::Model.default_association_options[:read_only] = false > > before loading your models to default to the Sequel 4 behavior of > automatically creating modification methods for each association. > > For many_to_one/one_to_one associations, I'm leaning towards still > defining the setter method by default, since it is only a single method and > is probably more commonly used than the one_to_many/many_to_many > modification methods. > > In one of my projects: > > 104 one_to_many/many_to_many associations > 26 needing modification methods (many only during testing and not during > production) > 78 not needing them > ~800KB memory saved by not defining unnecessary modification methods > > I would like to get some feedback from the community before making the > final decision. > > 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.
