Sha256: d3f5e3546a8e6d35a7389a156d0ae2295bf6c1bf0213c90cf5bf561c46f6cc3f

Contents?: true

Size: 949 Bytes

Versions: 80

Compression:

Stored size: 949 Bytes

Contents

require 'arel/visitors/compat'

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

      def visit_Arel_Nodes_SelectStatement o, a = nil
        sql = limit_offset(o.cores.map { |x| do_visit_select_core x, a }.join, o)
        sql << " ORDER BY #{o.orders.map { |x| do_visit x, a }.join(', ')}" unless o.orders.empty?
        sql
      end unless ArJdbc::AR42

      private

      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} 0 #{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-alt-adapter-61.3.0-java lib/arel/visitors/hsqldb.rb
activerecord-jdbc-adapter-61.3-java lib/arel/visitors/hsqldb.rb
activerecord-jdbc-alt-adapter-60.3.0-java lib/arel/visitors/hsqldb.rb
activerecord-jdbc-alt-adapter-61.2.0-java lib/arel/visitors/hsqldb.rb
activerecord-jdbc-adapter-70.0-java lib/arel/visitors/hsqldb.rb
activerecord-jdbc-adapter-70.0.pre-java lib/arel/visitors/hsqldb.rb
activerecord-jdbc-adapter-61.2-java lib/arel/visitors/hsqldb.rb
activerecord-jdbc-alt-adapter-60.2.0-java lib/arel/visitors/hsqldb.rb
activerecord-jdbc-alt-adapter-61.1.0-java lib/arel/visitors/hsqldb.rb
activerecord-jdbc-adapter-61.1-java lib/arel/visitors/hsqldb.rb
activerecord-jdbc-adapter-60.4-java lib/arel/visitors/hsqldb.rb
activerecord-jdbc-adapter-52.8-java lib/arel/visitors/hsqldb.rb
activerecord-jdbc-alt-adapter-61.0.0-java lib/arel/visitors/hsqldb.rb
activerecord-jdbc-alt-adapter-60.1.0-java lib/arel/visitors/hsqldb.rb
activerecord-jdbc-alt-adapter-52.6.0-java lib/arel/visitors/hsqldb.rb
activerecord-jdbc-alt-adapter-51.7.0-java lib/arel/visitors/hsqldb.rb
activerecord-jdbc-alt-adapter-50.7.0-java lib/arel/visitors/hsqldb.rb
activerecord-jdbc-adapter-61.0-java lib/arel/visitors/hsqldb.rb
activerecord-jdbc-adapter-60.3-java lib/arel/visitors/hsqldb.rb
activerecord-jdbc-adapter-52.7-java lib/arel/visitors/hsqldb.rb