2 ActiveRecord features I can offer: eager loading, optimized updates

If you can manage to persuade the community on ignoring the mutable methods by convention, I'll be happy to follow your lead... :smiley:

That's going to be the way for Active Record attributes. If you want dirty tracking (and partial updates), you don't get to do inplace modifications.

I think this might be a seriously awful suggestion because I’ve not thought it through beyond a 30sec irb trial, but could you .freeze what model.attribute supplies so that inplace mods won’t work? In my head it seems bad as I’m sure there are obvious holes in such an idea, but I can’t quite work out what they are.

For my own peace of mind, can someone convince me why it’s bad?

Muz

This is what my dirty plugin did. It works great in most cases, but falls down in others (Date#inspect modifies the instance, for example).

Just freezing String attributes works well, to prevent << and .gsub!

Anyone have compelling reasons not to treat attribute values as immutable?

jeremy

Huh. Funny thing, I submitted this functionality to the rails core in May 2007 (http://dev.rubyonrails.org/ticket/8520), but Jeremy turned it down as "This is cool but uncommonly needed" and mentioned "2x memory consumption"... I posted my implementation at BehindLogic.com is for sale | HugeDomains in August, and it turns out what went into trunk two weeks ago (http://dev.rubyonrails.org/browser/trunk/activerecord/lib/active_record/dirty.rb?rev=9127) uses the exact same logic and memory footprint.

Oh well. (no hard feelings!) I guess I'm glad it's going in after all.

Right now I'm working on "Lazy-loading facilitating smart eager-loading." (If you wait to load an object until you actually need it, you might find out you also need an associated object, or a whole group of them, and you can reduce it to one query.) Fun stuff. :slight_smile:

Oh well. (no hard feelings!) I guess I'm glad it's going in after all.

I personally prefer people who can change their mind on an issue when faced with convincing new evidence. One wonders how the world would look if this was a more common trait :wink:

Thanks for your effort back then, and if you have any additional features in mind, or old rejected-patches that you think we should reconsider, let us know :slight_smile:

Umm... Better, I'm guessing?

-- Chad