Sha256: 605230a2df5c3a0a8dec2411caf6e564f387fbc4a1337f7254e7daf0df16e0e3

Contents?: true

Size: 1.07 KB

Versions: 107

Compression:

Stored size: 1.07 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 = exec_query_raw(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[]
        #
        raw_result.map!(&:values)
        raw_result.join("\n")
      end
    end
  end
end

Version data entries

107 entries across 107 versions & 4 rubygems

Version Path
activerecord-jdbc-adapter-1.3.6 lib/arjdbc/hsqldb/explain_support.rb
activerecord-jdbc-adapter-1.3.5 lib/arjdbc/hsqldb/explain_support.rb
activerecord-jdbc-adapter-1.3.4 lib/arjdbc/hsqldb/explain_support.rb
activerecord-jdbc-adapter-1.3.3 lib/arjdbc/hsqldb/explain_support.rb
activerecord-jdbc-adapter-1.3.2 lib/arjdbc/hsqldb/explain_support.rb
activerecord-jdbc-adapter-1.3.1 lib/arjdbc/hsqldb/explain_support.rb
activerecord-jdbc-adapter-1.3.0 lib/arjdbc/hsqldb/explain_support.rb