Sha256: e77042ed2b7c76d1b7102d04ee61b7c82a455206b30ad63095199079b570384e

Contents?: true

Size: 637 Bytes

Versions: 2

Compression:

Stored size: 637 Bytes

Contents

module Arel
  module Visitors
    class HSQLDB < Arel::Visitors::ToSql
      def visit_Arel_Nodes_SelectStatement o
        [
          limit_offset(o.cores.map { |x| visit_Arel_Nodes_SelectCore x }.join, o),
          ("ORDER BY #{o.orders.map { |x| visit x }.join(', ')}" unless o.orders.empty?),
        ].compact.join ' '
      end

      def limit_offset sql, o
        offset = o.offset || 0
        bef = sql[7..-1]
        if limit = o.limit
          "SELECT LIMIT #{offset} #{limit} #{bef}"
        elsif offset > 0
          "SELECT LIMIT #{offset} 0 #{bef}"
        else
          sql
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
activerecord-jdbc-adapter-1.1.0 lib/arel/visitors/hsqldb.rb
activerecord-jdbc-adapter-1.0.3-java lib/arel/visitors/hsqldb.rb