From f5ea6f880f365c5383d029bddc917baa82e56d55 Mon Sep 17 00:00:00 2001 From: Rick Olson Date: Wed, 25 Jul 2007 03:48:30 +0000 Subject: 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 --- activerecord/lib/active_record/query_cache.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'activerecord/lib') 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) -- cgit v1.2.3