aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2015-12-27 23:12:41 +0900
committerRyuta Kamizono <kamipo@gmail.com>2015-12-27 23:12:41 +0900
commitbf79aa4fc14aeb2646331e767038acf0b77e9e7f (patch)
treeea732e021574697e7bf3b6495b0bc85192164d80 /activerecord/test
parentd5363e58135ea279f2a08c1a2d852ae2d11f0d65 (diff)
downloadrails-bf79aa4fc14aeb2646331e767038acf0b77e9e7f.tar.gz
rails-bf79aa4fc14aeb2646331e767038acf0b77e9e7f.tar.bz2
rails-bf79aa4fc14aeb2646331e767038acf0b77e9e7f.zip
Improve `select_one` in `Mysql2Adapter`
Avoid instanciate `ActiveRecord::Result` and calling `ActiveRecord::Result#hash_rows` for the performance.
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/adapters/mysql2/sp_test.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/activerecord/test/cases/adapters/mysql2/sp_test.rb b/activerecord/test/cases/adapters/mysql2/sp_test.rb
index cdaa2cca44..4197ba45f1 100644
--- a/activerecord/test/cases/adapters/mysql2/sp_test.rb
+++ b/activerecord/test/cases/adapters/mysql2/sp_test.rb
@@ -22,6 +22,12 @@ class Mysql2StoredProcedureTest < ActiveRecord::Mysql2TestCase
assert @connection.active?, "Bad connection use by 'Mysql2Adapter.select_rows'"
end
+ def test_multi_results_from_select_one
+ row = @connection.select_one('CALL topics(1);')
+ assert_equal 'David', row['author_name']
+ assert @connection.active?, "Bad connection use by 'Mysql2Adapter.select_one'"
+ end
+
def test_multi_results_from_find_by_sql
topics = Topic.find_by_sql 'CALL topics(3);'
assert_equal 3, topics.size