aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/adapters/postgresql/explain_test.rb
blob: 0d599ed37fc8939d627a21bd79245bf30fd4d6ea (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
require "cases/helper"
require 'models/developer'

module ActiveRecord
  module ConnectionAdapters
    class PostgreSQLAdapter
      class ExplainTest < ActiveRecord::TestCase
        fixtures :developers

        def test_explain_for_one_query
          explain = Developer.where(:id => 1).explain
          assert_match %(QUERY PLAN), explain
          assert_match %(Index Scan using developers_pkey on developers), explain
        end

        def test_explain_with_eager_loading
          explain = Developer.where(:id => 1).includes(:audit_logs).explain
          assert_match %(QUERY PLAN), explain
          assert_match %(Index Scan using developers_pkey on developers), explain
          assert_match %(Seq Scan on audit_logs), explain
        end
      end
    end
  end
end