Module: ArJdbc::PostgreSQL::DatabaseStatements

Included in:
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
Defined in:
lib/arjdbc/postgresql/database_statements.rb

Instance Method Summary collapse

Instance Method Details

#build_explain_clause(options = []) ⇒ Object



13
14
15
16
17
# File 'lib/arjdbc/postgresql/database_statements.rb', line 13

def build_explain_clause(options = [])
  return "EXPLAIN" if options.empty?

  "EXPLAIN (#{options.join(", ").upcase})"
end

#explain(arel, binds = [], options = []) ⇒ Object



6
7
8
9
10
11
# File 'lib/arjdbc/postgresql/database_statements.rb', line 6

def explain(arel, binds = [], options = [])
  sql    = build_explain_clause(options) + " " + to_sql(arel, binds)

  result = internal_exec_query(sql, "EXPLAIN", binds)
  ActiveRecord::ConnectionAdapters::PostgreSQL::ExplainPrettyPrinter.new.pp(result)
end