Permalink
Browse files

dont call #collect on a string when returning query cache results. Cl…

…oses #9099 [norbert]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7239 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent f5ea6f8 commit ea07212d9780841fbfb3368247ccc0b4bdee5bf5 @technoweenie technoweenie committed Jul 25, 2007
Showing with 7 additions and 1 deletion.
  1. +1 −1 activerecord/lib/active_record/query_cache.rb
  2. +6 −0 activerecord/test/query_cache_test.rb
@@ -61,7 +61,7 @@ def cache(sql)
if result
# perform a deep #dup in case result is an array
- result = result.collect { |row| row.dup } if result.respond_to?(:collect)
+ result = result.collect { |row| row.dup } if result.is_a?(Array)
result.dup
else
nil
@@ -57,6 +57,12 @@ def test_cache_does_not_blow_up_other_connections
"Connections should be different, Course connects to a different database"
end
end
+
+ def test_cache_does_not_wrap_string_results_in_arrays
+ Task.cache do
+ assert_instance_of String, Task.connection.select_value("SELECT count(*) AS count_all FROM tasks")
+ end
+ end
end
uses_mocha('QueryCacheExpiryTest') do

0 comments on commit ea07212

Please sign in to comment.