From b18d9568a64b9b3605db90f93e6fcbf77344d010 Mon Sep 17 00:00:00 2001 From: Michael Koziarski Date: Sun, 2 Sep 2007 23:52:58 +0000 Subject: Ensure QueryCache doesn't try to dup numeric results (does not affect the major OS database). Closes #7661 [tomafro, nzkoz] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7399 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/lib/active_record/query_cache.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/query_cache.rb b/activerecord/lib/active_record/query_cache.rb index e25335ecea..e598de07e2 100644 --- a/activerecord/lib/active_record/query_cache.rb +++ b/activerecord/lib/active_record/query_cache.rb @@ -59,12 +59,13 @@ module ActiveRecord @query_cache[sql] = yield end - if result - # perform a deep #dup in case result is an array - result = result.collect { |row| row.dup } if result.is_a?(Array) - result.dup + case result + when Array + result.collect { |row| row.dup } + when Numeric, NilClass, FalseClass + result else - nil + result.dup end end -- cgit v1.2.3