Add an identity map to ActiveRecord
Like in DataMapper.
5 comments
-
Mario T. Lanza
commented
This is above all the greatest shortcoming to AR. It's almost a deal breaker and has me evaluating Sequel and other ORMs for an upcoming project. In one project I am working with highly intertwined database structures. The same records are frequently reloaded due to the way the business objects are navigated. Identity Map could solve this headache.
-
gregd
commented
class Parent
has_many :children
endclass Child
belongs_to :parent
validate_presence_of :parent_id
endNow above simple code fails if parent and child records are created via nested forms (Rails 2.3 feature). I hope that with identity map, child records could have a reference to the parent object which exists only in memory. So validations like above and other non-trivial code also works.
-
Venkat K
commented
I have AR objects which have parent child relationships (many are nested sets but even otherwise there are two or three level table relationships) this is becoming a important necessity
Parental Kontrol could be one useful plugin to give some relieve onw
-
Luismi Cavallé
commented
I wasn't used to miss this functionality but lately I periodically get into advanced issues were i'd be really nice to have identity map in ActiveRecord. I also think some internals of ActiveRecord would be simplified and so further maintenance.
-
Otto Hilska commented
Not having an identity map forces me to write ugly hacks to avoid the performance problems.