Rails 3.1 Identity Map问题?

mat*_*sko 10 ruby-on-rails identity-map ruby-on-rails-3

有谁知道Rails 3.1 IdentityMap功能的主要问题是强制默认禁用该功能?我确信存在一些小问题,但在为已经构建的Rails 3.1应用程序启用它之前,是否有任何人应该注意的重大问题?

Mor*_*ori 9

代码中注释:

# 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 accidently removed.
#
# This inconsistency is meant to be fixed in future Rails releases.
Run Code Online (Sandbox Code Playgroud)


Mau*_*res 8

当您查看文档时,提出的主要问题是Identity Map中管理的对象还无法处理关联,因此现在还没有为现实世界的使用做好准备.

文档清楚地表明该功能仍处于开发阶段,因此没有人应该真正在野外使用它.