Module: ArJdbc::SQLite3::ExplainSupport

Included in:
ActiveRecord::ConnectionAdapters::SQLite3Adapter
Defined in:
lib/arjdbc/sqlite3/explain_support.rb

Defined Under Namespace

Classes: ExplainPrettyPrinter

Instance Method Summary collapse

Instance Method Details

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



8
9
10
11
12
13
14
15
# File 'lib/arjdbc/sqlite3/explain_support.rb', line 8

def explain(arel, binds = [])
  sql = "EXPLAIN QUERY PLAN #{to_sql(arel, binds)}"
  raw_result  = execute(sql, "EXPLAIN", binds)
  # TODO we should refactor to exce_query once it returns Result ASAP :
  keys = raw_result[0] ? raw_result[0].keys : {}
  rows = raw_result.map { |hash| hash.values }
  ExplainPrettyPrinter.new.pp ActiveRecord::Result.new(keys, rows)
end

#supports_explain?Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/arjdbc/sqlite3/explain_support.rb', line 4

def supports_explain?
  true
end