diff options
author | Rick Olson <technoweenie@gmail.com> | 2007-07-25 03:48:30 +0000 |
---|---|---|
committer | Rick Olson <technoweenie@gmail.com> | 2007-07-25 03:48:30 +0000 |
commit | f5ea6f880f365c5383d029bddc917baa82e56d55 (patch) | |
tree | b14e2d0a722dedff18f85918c3e70b73ab6a406c /activerecord/lib | |
parent | d51e7f8252269492a511a9eb41f2832646a44248 (diff) | |
download | rails-f5ea6f880f365c5383d029bddc917baa82e56d55.tar.gz rails-f5ea6f880f365c5383d029bddc917baa82e56d55.tar.bz2 rails-f5ea6f880f365c5383d029bddc917baa82e56d55.zip |
Perform a deep #dup on query cache results so that modifying activerecord attributes does not modify the cached attributes. [Rick]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7238 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/query_cache.rb | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/query_cache.rb b/activerecord/lib/active_record/query_cache.rb index 9296c5b81a..191e5a3d97 100644 --- a/activerecord/lib/active_record/query_cache.rb +++ b/activerecord/lib/active_record/query_cache.rb @@ -58,8 +58,14 @@ module ActiveRecord else @query_cache[sql] = yield end - - result ? result.dup : nil + + if result + # perform a deep #dup in case result is an array + result = result.collect { |row| row.dup } if result.respond_to?(:collect) + result.dup + else + nil + end end def method_missing(method, *arguments, &proc) |