Navigation Menu

Skip to content

Commit

Permalink
fixing tests to deal with data differences between prepared statement…
Browse files Browse the repository at this point in the history
…s and non-prepared statements
  • Loading branch information
tenderlove committed Jul 13, 2012
1 parent 8f43230 commit f7ef7ca
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 4 additions & 1 deletion activerecord/test/cases/adapters/mysql/connection_test.rb
Expand Up @@ -70,11 +70,14 @@ def test_exec_no_binds
assert_equal %w{ id data }, result.columns

@connection.exec_query('INSERT INTO ex (id, data) VALUES (1, "foo")')

# if there are no bind parameters, it will return a string (due to
# the libmysql api)
result = @connection.exec_query('SELECT id, data FROM ex')
assert_equal 1, result.rows.length
assert_equal 2, result.columns.length

assert_equal [[1, 'foo']], result.rows
assert_equal [['1', 'foo']], result.rows
end

def test_exec_with_binds
Expand Down
4 changes: 3 additions & 1 deletion activerecord/test/cases/adapters/mysql/mysql_adapter_test.rb
Expand Up @@ -30,7 +30,9 @@ def test_exec_insert_number
result = @conn.exec_query('SELECT number FROM ex WHERE number = 10')

assert_equal 1, result.rows.length
assert_equal 10, result.rows.last.last
# if there are no bind parameters, it will return a string (due to
# the libmysql api)
assert_equal '10', result.rows.last.last
end

def test_exec_insert_string
Expand Down
2 changes: 1 addition & 1 deletion activerecord/test/cases/query_cache_test.rb
Expand Up @@ -156,7 +156,7 @@ def test_cache_does_not_wrap_string_results_in_arrays
# Oracle adapter returns count() as Fixnum 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) && sqlite3_version > '1.2.5' || current_adapter?(:Mysql2Adapter) || current_adapter?(:MysqlAdapter)
elsif current_adapter?(:SQLite3Adapter) && sqlite3_version > '1.2.5' || current_adapter?(:Mysql2Adapter)
# Future versions of the sqlite3 adapter will return numeric
assert_instance_of Fixnum,
Task.connection.select_value("SELECT count(*) AS count_all FROM tasks")
Expand Down

0 comments on commit f7ef7ca

Please sign in to comment.