aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/query_cache_test.rb
diff options
context:
space:
mode:
authorYasuo Honda <yasuo.honda@gmail.com>2017-09-01 12:18:56 +0000
committerYasuo Honda <yasuo.honda@gmail.com>2017-09-01 15:57:02 +0000
commitcb2934ed79286f46c1e5593dd4c34aebfb2bc4d6 (patch)
treea43fa317530376c1b02e06e2158d633a5592d9f0 /activerecord/test/cases/query_cache_test.rb
parent806f96ceaecbf9cf8d2fdbbdaf1fb2a499769cbf (diff)
downloadrails-cb2934ed79286f46c1e5593dd4c34aebfb2bc4d6.tar.gz
rails-cb2934ed79286f46c1e5593dd4c34aebfb2bc4d6.tar.bz2
rails-cb2934ed79286f46c1e5593dd4c34aebfb2bc4d6.zip
sqlite3 adapter returns integer value which used to be string
`to_i` was added for SQLite3 adapter which did not handle number but sqlite3 gem already supports it then `to_i` is unnecessary. else condition is kept for adapters which return string, i.e. mysql(not mysql2) and sqlserver. Renamed `test_cache_does_not_wrap_string_results_in_arrays` to `test_cache_does_not_wrap_results_in_arrays` to explain the current behavior. most of adapters return integer, not only string. * Refer these commits: "future proofing the sqlite3 adapter code" https://github.com/rails/rails/commit/beda2d43d6ac5c3435fc2fba0cbd108c20fe1c67 "Refactor calculation test to remove unneeded SQLite special case." https://github.com/rails/rails/commit/47d568ed3fc701934ebe80b276f3d8bf6951c93f "no need to to_i, sqlite does that for us" https://github.com/rails/rails/commit/6cf44a1bd64ba10497742d70ad78fe68faa16e99
Diffstat (limited to 'activerecord/test/cases/query_cache_test.rb')
-rw-r--r--activerecord/test/cases/query_cache_test.rb10
1 files changed, 3 insertions, 7 deletions
diff --git a/activerecord/test/cases/query_cache_test.rb b/activerecord/test/cases/query_cache_test.rb
index d3f4b5bf75..5cb537b623 100644
--- a/activerecord/test/cases/query_cache_test.rb
+++ b/activerecord/test/cases/query_cache_test.rb
@@ -302,14 +302,10 @@ class QueryCacheTest < ActiveRecord::TestCase
end
end
- def test_cache_does_not_wrap_string_results_in_arrays
+ def test_cache_does_not_wrap_results_in_arrays
Task.cache do
- # Oracle adapter returns count() as Integer or Float
- if current_adapter?(:OracleAdapter)
- assert_kind_of Numeric, Task.connection.select_value("SELECT count(*) AS count_all FROM tasks")
- elsif current_adapter?(:SQLite3Adapter, :Mysql2Adapter, :PostgreSQLAdapter)
- # Future versions of the sqlite3 adapter will return numeric
- assert_instance_of 0.class, Task.connection.select_value("SELECT count(*) AS count_all FROM tasks")
+ if current_adapter?(:SQLite3Adapter, :Mysql2Adapter, :PostgreSQLAdapter, :OracleAdapter)
+ assert_equal 2, Task.connection.select_value("SELECT count(*) AS count_all FROM tasks")
else
assert_instance_of String, Task.connection.select_value("SELECT count(*) AS count_all FROM tasks")
end