Sha256: e3d469ca20bd535b21fe909c1e2bb5f0665513441f111441cefc3d41324b407c

Contents?: true

Size: 854 Bytes

Versions: 6

Compression:

Stored size: 854 Bytes

Contents

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

class PostgreSQLExplainTest < ActiveRecord::PostgreSQLTestCase
  fixtures :developers

  def test_explain_for_one_query
    explain = Developer.where(id: 1).explain
    assert_match %r(EXPLAIN for: SELECT "developers".* FROM "developers" WHERE "developers"."id" = (?:\$1 \[\["id", 1\]\]|1)), explain
    assert_match %(QUERY PLAN), explain
  end

  def test_explain_with_eager_loading
    explain = Developer.where(id: 1).includes(:audit_logs).explain
    assert_match %(QUERY PLAN), explain
    assert_match %r(EXPLAIN for: SELECT "developers".* FROM "developers" WHERE "developers"."id" = (?:\$1 \[\["id", 1\]\]|1)), explain
    assert_match %(EXPLAIN for: SELECT "audit_logs".* FROM "audit_logs" WHERE "audit_logs"."developer_id" = 1), explain
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

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