Sha256: c82b35f7281825fda655f79981dc8bbb2feb71c149077d827c3426a0a22e9bee

Contents?: true

Size: 1.08 KB

Versions: 6

Compression:

Stored size: 1.08 KB

Contents

module ArJdbc
  module HSQLDB
    module ExplainSupport
      def supports_explain?; true; end
      
      def explain(arel, binds = [])
        sql = "EXPLAIN PLAN FOR #{to_sql(arel, binds)}"
        raw_result  = execute(sql, "EXPLAIN", binds)
        # HSQLDB's SqlTool just prints it as it comes :
        # 
        #  sql> EXPLAIN PLAN FOR SELECT * FROM entries JOIN users on ... ;
        #  
        # isDistinctSelect=[false]
        # isGrouped=[false]
        # isAggregated=[false]
        # columns=[  COLUMN: PUBLIC.ENTRIES.ID
        #  not nullable  COLUMN: PUBLIC.ENTRIES.TITLE
        #  nullable  COLUMN: PUBLIC.ENTRIES.UPDATED_ON
        #  nullable  COLUMN: PUBLIC.ENTRIES.CONTENT
        #  nullable  COLUMN: PUBLIC.ENTRIES.RATING
        #  nullable  COLUMN: PUBLIC.ENTRIES.USER_ID
        #  nullable  COLUMN: PUBLIC.USERS.ID
        #  not nullable  COLUMN: PUBLIC.USERS.LOGIN
        #  nullable
        # ]
        # ...
        # PARAMETERS=[]
        # SUBQUERIES[]
        #
        rows = raw_result.map { |hash| hash.values }
        rows.join("\n")
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
activerecord-jdbc-adapter-1.3.0.rc1 lib/arjdbc/hsqldb/explain_support.rb
activerecord-jdbc-adapter-1.2.9.1 lib/arjdbc/hsqldb/explain_support.rb
activerecord-jdbc-adapter-1.3.0.beta2 lib/arjdbc/hsqldb/explain_support.rb
activerecord-jdbc-adapter-1.3.0.beta1 lib/arjdbc/hsqldb/explain_support.rb
activerecord-jdbc-adapter-1.2.9 lib/arjdbc/hsqldb/explain_support.rb
activerecord-jdbc-adapter-1.2.8 lib/arjdbc/hsqldb/explain_support.rb