diff options
Diffstat (limited to 'activerecord/test/cases/explain_test.rb')
-rw-r--r-- | activerecord/test/cases/explain_test.rb | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/activerecord/test/cases/explain_test.rb b/activerecord/test/cases/explain_test.rb index cb7781f8e7..6dce8ccdd1 100644 --- a/activerecord/test/cases/explain_test.rb +++ b/activerecord/test/cases/explain_test.rb @@ -20,7 +20,7 @@ if ActiveRecord::Base.connection.supports_explain? end with_threshold(0) do - Car.where(:name => 'honda').all + Car.where(:name => 'honda').to_a end end @@ -45,7 +45,7 @@ if ActiveRecord::Base.connection.supports_explain? queries = Thread.current[:available_queries_for_explain] = [] with_threshold(0) do - Car.where(:name => 'honda').all + Car.where(:name => 'honda').to_a end sql, binds = queries[0] @@ -58,7 +58,7 @@ if ActiveRecord::Base.connection.supports_explain? def test_collecting_queries_for_explain result, queries = ActiveRecord::Base.collecting_queries_for_explain do - Car.where(:name => 'honda').all + Car.where(:name => 'honda').to_a end sql, binds = queries[0] @@ -68,6 +68,16 @@ if ActiveRecord::Base.connection.supports_explain? assert_equal [cars(:honda)], result end + def test_logging_query_plan_when_counting_by_sql + base.logger.expects(:warn).with do |message| + message.starts_with?('EXPLAIN for:') + end + + with_threshold(0) do + Car.count_by_sql "SELECT COUNT(*) FROM cars WHERE name = 'honda'" + end + end + def test_exec_explain_with_no_binds sqls = %w(foo bar) binds = [[], []] |