Sha256: 13071dc6ab75e3eaed8f71987a9bf77bc6ccb9b3b2ced7ac265c87cb8be8f2b1

Contents?: true

Size: 686 Bytes

Versions: 80

Compression:

Stored size: 686 Bytes

Contents

require 'arel/visitors/compat'
require 'arel/visitors/hsqldb'

module Arel
  module Visitors
    class H2 < Arel::Visitors::HSQLDB
      def visit_Arel_Nodes_SelectStatement(o, *)
        o.limit ||= Arel::Nodes::Limit.new(-1) if o.offset
        super
      end if ArJdbc::AR42

      def limit_offset sql, o
        offset = o.offset || 0
        offset = offset.expr unless (offset.nil? || offset == 0)
        if limit = o.limit
          "SELECT LIMIT #{offset} #{limit_for(limit)} #{sql[7..-1]}"
        elsif offset > 0
          "SELECT LIMIT #{offset} -1 #{sql[7..-1]}" # removes "SELECT "
        else
          sql
        end
      end unless ArJdbc::AR42
    end
  end
end

Version data entries

80 entries across 80 versions & 4 rubygems

Version Path
activerecord-jdbc-adapter-51.3-java lib/arel/visitors/h2.rb
activerecord-jdbc-adapter-50.3-java lib/arel/visitors/h2.rb
activerecord-jdbc-adapter-52.1-java lib/arel/visitors/h2.rb
activerecord-jdbc-adapter-51.2-java lib/arel/visitors/h2.rb
activerecord-jdbc-adapter-50.2-java lib/arel/visitors/h2.rb
activerecord-jdbc-adapter-1.3.25 lib/arel/visitors/h2.rb
activerecord-jdbc-adapter-52.0-java lib/arel/visitors/h2.rb
activerecord-jdbc-adapter-51.1-java lib/arel/visitors/h2.rb
activerecord-jdbc-adapter-50.1-java lib/arel/visitors/h2.rb
activerecord-jdbc-adapter-51.0 lib/arel/visitors/h2.rb
activerecord-jdbc-adapter-1.3.24 lib/arel/visitors/h2.rb
neo-activerecord-jdbc-adapter-5.0.pre2 lib/arel/visitors/h2.rb
activerecord-jdbc-adapter-ficoh-1.3.21-java lib/arel/visitors/h2.rb
activerecord-jdbc-adapter-1.3.23 lib/arel/visitors/h2.rb
activerecord-jdbc-adapter-1.3.22 lib/arel/visitors/h2.rb
activerecord-jdbc-adapter-5.0.pre1 lib/arel/visitors/h2.rb
activerecord-jdbc-adapter-1.3.21 lib/arel/visitors/h2.rb
activerecord-jdbc-adapter-1.3.20 lib/arel/visitors/h2.rb
activerecord-jdbc-adapter-1.3.19 lib/arel/visitors/h2.rb
activerecord-jdbc-adapter-1.3.18 lib/arel/visitors/h2.rb