aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2011-05-10 11:33:39 +0200
committerJosé Valim <jose.valim@gmail.com>2011-05-10 11:33:39 +0200
commit302c912bf6bcd0fa200d964ec2dc4a44abe328a6 (patch)
treec5dddb0ab1053775525e40934d72b260b051861c /activerecord
parent5fc3564a5021909384d2b762d125e521683403f1 (diff)
downloadrails-302c912bf6bcd0fa200d964ec2dc4a44abe328a6.tar.gz
rails-302c912bf6bcd0fa200d964ec2dc4a44abe328a6.tar.bz2
rails-302c912bf6bcd0fa200d964ec2dc4a44abe328a6.zip
Document identity map inconsistency with associations, closes #474.
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/identity_map.rb29
1 files changed, 28 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/identity_map.rb b/activerecord/lib/active_record/identity_map.rb
index cad3865f03..61221f24b4 100644
--- a/activerecord/lib/active_record/identity_map.rb
+++ b/activerecord/lib/active_record/identity_map.rb
@@ -12,7 +12,34 @@ module ActiveRecord
# In order to enable IdentityMap, set <tt>config.active_record.identity_map = true</tt>
# in your <tt>config/application.rb</tt> file.
#
- # IdentityMap is disabled by default.
+ # IdentityMap is disabled by default and still in development (i.e. use it with care).
+ #
+ # == Associations
+ #
+ # Active Record Identity Map does not track associations yet. For example:
+ #
+ # comment = @post.comments.first
+ # comment.post = nil
+ # @post.comments.include?(comment) #=> true
+ #
+ # Ideally, the example above would return false, removing the comment object from the
+ # post association when the association is nullified. This may cause side effects, as
+ # in the situation below, if Identity Map is enabled:
+ #
+ # Post.has_many :comments, :dependent => :destroy
+ #
+ # comment = @post.comments.first
+ # comment.post = nil
+ # comment.save
+ # Post.destroy(@post.id)
+ #
+ # Without using Identity Map, the code above will destroy the @post object leaving
+ # the comment object intact. However, once we enable Identity Map, the post loaded
+ # by Post.destroy is exactly the same object as the object @post. As the object @post
+ # still has the comment object in @post.comments, once Identity Map is enabled, the
+ # comment object will be acciddently removed.
+ #
+ # This incosistency is meant to be fixed in future Rails releases.
#
module IdentityMap