Sha256: 91746692ec04b33af041a247e1d1b7d6b68d72063065db12fbece6adf0650d7b

Contents?: true

Size: 1 KB

Versions: 2

Compression:

Stored size: 1 KB

Contents

require "cases/helper"
require 'models/developer'
require 'models/computer'

module ActiveRecord
  module ConnectionAdapters
    class Mysql2Adapter
      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` IN (1)), explain
          assert_match %r(audit_logs |.* ALL), explain
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
activejob-lock-0.0.2 rails/activerecord/test/cases/adapters/mysql2/explain_test.rb
activejob-lock-0.0.1 rails/activerecord/test/cases/adapters/mysql2/explain_test.rb