On Mar 20, 9:28 am, funny_falcon <[email protected]> wrote: > Problem: > - wants to copy fields from one model instance to other many times > fast (1000 instances at once). > Simplest solution would be abusing `values` hash, but I also want to > keep `changed_columns` tracking. > > Currenlty I solve it by copying `[]=` method without calling > `typecast_value`: > > module Sequel > class Model > def set_wo_typecast(column, value) > if new? || [email protected]?(column) || value != (c = > @values[column]) || value.class != c.class > changed_columns << column unless changed_columns.include? > (column) > @values[column] = value > end > end > end > end > > Perhaps it is good candidate to be a standard method (maybe with > different name). What do you think?
I don't think it is used nearly often enough to make it a standard method. You can just turn off typecasting for that model class or even that particular instance: ModelClass.typecast_on_assignment = false model_instance.typecast_on_assignment = false The least invasive way to do what you want currently is just to call typecast_on_assignment = false on the instance before calling set. Jeremy -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sequel-talk?hl=en.
