diff options
author | Jeremy Daer <jeremydaer@gmail.com> | 2015-09-19 17:17:57 -0700 |
---|---|---|
committer | Jeremy Daer <jeremydaer@gmail.com> | 2015-09-19 17:17:57 -0700 |
commit | d3f2c59bdd4f91a1562e6c405a9b2dc62163d943 (patch) | |
tree | 487a9d4dfeb4872598b849817d597e716d182745 /activerecord/test | |
parent | 5837de5360b9a38ca5b07f26b1d03b1ce4763f17 (diff) | |
parent | d2bf188bcf87b9dc8f6dda533aa8a24a18b2e166 (diff) | |
download | rails-d3f2c59bdd4f91a1562e6c405a9b2dc62163d943.tar.gz rails-d3f2c59bdd4f91a1562e6c405a9b2dc62163d943.tar.bz2 rails-d3f2c59bdd4f91a1562e6c405a9b2dc62163d943.zip |
Merge pull request #19086 from kamipo/move_explain_into_abstract_mysql_adapter
Move `explain` into `AbstractMysqlAdapter`
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/adapters/mysql/explain_test.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/activerecord/test/cases/adapters/mysql/explain_test.rb b/activerecord/test/cases/adapters/mysql/explain_test.rb new file mode 100644 index 0000000000..f75386abb9 --- /dev/null +++ b/activerecord/test/cases/adapters/mysql/explain_test.rb @@ -0,0 +1,27 @@ +require "cases/helper" +require 'models/developer' +require 'models/computer' + +module ActiveRecord + module ConnectionAdapters + class MysqlAdapter + class ExplainTest < ActiveRecord::TestCase + fixtures :developers + + def test_explain_for_one_query + explain = Developer.where(:id => 1).explain + assert_match %(EXPLAIN for: SELECT `developers`.* FROM `developers` WHERE `developers`.`id` = 1), explain + assert_match %r(developers |.* const), explain + end + + def test_explain_with_eager_loading + explain = Developer.where(:id => 1).includes(:audit_logs).explain + assert_match %(EXPLAIN for: SELECT `developers`.* FROM `developers` WHERE `developers`.`id` = 1), explain + assert_match %r(developers |.* const), explain + assert_match %(EXPLAIN for: SELECT `audit_logs`.* FROM `audit_logs` WHERE `audit_logs`.`developer_id` = 1), explain + assert_match %r(audit_logs |.* ALL), explain + end + end + end + end +end |