aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorRick Olson <technoweenie@gmail.com>2007-07-25 03:48:30 +0000
committerRick Olson <technoweenie@gmail.com>2007-07-25 03:48:30 +0000
commitf5ea6f880f365c5383d029bddc917baa82e56d55 (patch)
treeb14e2d0a722dedff18f85918c3e70b73ab6a406c /activerecord/lib
parentd51e7f8252269492a511a9eb41f2832646a44248 (diff)
downloadrails-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.rb10
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)