Sha256: 341abd9e83eb2a68b003356f5a66320456fa2986dec0f98f3461eb8ef6e34d95

Contents?: true

Size: 847 Bytes

Versions: 8

Compression:

Stored size: 847 Bytes

Contents

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

class Mysql2ExplainTest < ActiveRecord::Mysql2TestCase
  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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ibm_db-5.2.0 test/cases/adapters/mysql2/explain_test.rb
ibm_db-5.1.0 test/cases/adapters/mysql2/explain_test.rb
ibm_db-5.0.5 test/cases/adapters/mysql2/explain_test.rb
ibm_db-5.0.4 test/cases/adapters/mysql2/explain_test.rb
ibm_db-5.0.3 test/cases/adapters/mysql2/explain_test.rb
ibm_db-5.0.2 test/cases/adapters/mysql2/explain_test.rb
ibm_db-4.0.0-x86-mingw32 test/cases/adapters/mysql2/explain_test.rb
ibm_db-4.0.0 test/cases/adapters/mysql2/explain_test.rb