aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-01-26 13:00:19 -0800
committerYehuda Katz <wycats@Yehuda-Katz.local>2010-01-26 15:09:11 -0800
commitbeda2d43d6ac5c3435fc2fba0cbd108c20fe1c67 (patch)
tree0a03e0fd54501907544498a10a44f87bd45d2a8f /activerecord/test
parent6404feee500dc5a2268da1e41af08a5ff847338a (diff)
downloadrails-beda2d43d6ac5c3435fc2fba0cbd108c20fe1c67.tar.gz
rails-beda2d43d6ac5c3435fc2fba0cbd108c20fe1c67.tar.bz2
rails-beda2d43d6ac5c3435fc2fba0cbd108c20fe1c67.zip
future proofing the sqlite3 adapter code
Signed-off-by: Yehuda Katz <wycats@Yehuda-Katz.local>
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/calculations_test.rb3
-rw-r--r--activerecord/test/cases/query_cache_test.rb6
2 files changed, 9 insertions, 0 deletions
diff --git a/activerecord/test/cases/calculations_test.rb b/activerecord/test/cases/calculations_test.rb
index c3b2e56387..e6d56a7193 100644
--- a/activerecord/test/cases/calculations_test.rb
+++ b/activerecord/test/cases/calculations_test.rb
@@ -288,6 +288,9 @@ class CalculationsTest < ActiveRecord::TestCase
# Oracle adapter returns floating point value 636.0 after SUM
if current_adapter?(:OracleAdapter)
assert_equal 636, Account.sum("2 * credit_limit")
+ elsif current_adapter?(:SQLite3Adapter)
+ # Future versions of the SQLite3 adapter will return a number
+ assert_equal 636, Account.sum("2 * credit_limit").to_i
else
assert_equal '636', Account.sum("2 * credit_limit")
end
diff --git a/activerecord/test/cases/query_cache_test.rb b/activerecord/test/cases/query_cache_test.rb
index 2af6a56b6a..3710f8e40b 100644
--- a/activerecord/test/cases/query_cache_test.rb
+++ b/activerecord/test/cases/query_cache_test.rb
@@ -49,10 +49,16 @@ class QueryCacheTest < ActiveRecord::TestCase
end
def test_cache_does_not_wrap_string_results_in_arrays
+ require 'sqlite3/version' if current_adapter?(:SQLite3Adapter)
+
Task.cache do
# Oracle adapter returns count() as Fixnum or Float
if current_adapter?(:OracleAdapter)
assert Task.connection.select_value("SELECT count(*) AS count_all FROM tasks").is_a?(Numeric)
+ elsif current_adapter?(:SQLite3Adapter) && SQLite3::Version::VERSION > '1.2.5'
+ # Future versions of the sqlite3 adapter will return numeric
+ assert_instance_of Fixnum,
+ 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