1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

dont call #collect on a string when returning query cache results. Closes #9099 [norbert]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7239 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
Rick Olson 2007-07-25 13:05:58 +00:00
parent f5ea6f880f
commit ea07212d97
2 changed files with 7 additions and 1 deletions

View file

@ -61,7 +61,7 @@ module ActiveRecord
if result if result
# perform a deep #dup in case result is an array # 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 result.dup
else else
nil nil

View file

@ -57,6 +57,12 @@ class QueryCacheTest < Test::Unit::TestCase
"Connections should be different, Course connects to a different database" "Connections should be different, Course connects to a different database"
end end
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 end
uses_mocha('QueryCacheExpiryTest') do uses_mocha('QueryCacheExpiryTest') do