Sha256: aa4a51acdfec03df1317baf36d4d678d3ce3cc778d77b1a8c5e4cc51a595da8b

Contents?: true

Size: 849 Bytes

Versions: 6

Compression:

Stored size: 849 Bytes

Contents

# frozen_string_literal: true

require "cases/helper"
require "models/author"
require "models/post"

class PostgreSQLExplainTest < ActiveRecord::PostgreSQLTestCase
  fixtures :authors

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

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ibm_db-5.5.1 test/cases/adapters/postgresql/explain_test.rb
ibm_db-5.5.0 test/cases/adapters/postgresql/explain_test.rb
ibm_db-5.4.1 test/cases/adapters/postgresql/explain_test.rb
ibm_db-5.4.0 test/cases/adapters/postgresql/explain_test.rb
ibm_db-5.3.2 test/cases/adapters/postgresql/explain_test.rb
ibm_db-5.3.1 test/cases/adapters/postgresql/explain_test.rb