Sha256: 0c0ea2e805f7c48cfc3e59a647053402ab49643860418c6f4fa96616efdf9e10

Contents?: true

Size: 689 Bytes

Versions: 15

Compression:

Stored size: 689 Bytes

Contents

require 'arel/visitors/compat'

module Arel
  module Visitors
    class DB2 < Arel::Visitors::ToSql

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

      private

      def add_limit_offset(sql, o)
        if o.offset && o.offset.value && o.limit && o.limit.value
          @connection.replace_limit_offset_for_arel! o, sql
        else
          @connection.replace_limit_offset! sql, limit_for(o.limit), o.offset && o.offset.value
        end
      end

    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
activerecord-jdbc-adapter-1.3.13 lib/arel/visitors/db2.rb
activerecord-jdbc-adapter-1.3.12 lib/arel/visitors/db2.rb
activerecord-jdbc-adapter-1.3.11 lib/arel/visitors/db2.rb
activerecord-jdbc-adapter-1.3.10 lib/arel/visitors/db2.rb
activerecord-jdbc-adapter-1.3.9 lib/arel/visitors/db2.rb
activerecord-jdbc-adapter-1.3.8 lib/arel/visitors/db2.rb
activerecord-jdbc-adapter-1.3.7 lib/arel/visitors/db2.rb
activerecord-jdbc-adapter-1.3.6 lib/arel/visitors/db2.rb
activerecord-jdbc-adapter-1.3.5 lib/arel/visitors/db2.rb
activerecord-jdbc-adapter-1.3.4 lib/arel/visitors/db2.rb
activerecord-jdbc-adapter-1.3.3 lib/arel/visitors/db2.rb
activerecord-jdbc-adapter-1.3.2 lib/arel/visitors/db2.rb
activerecord-jdbc-adapter-1.3.1 lib/arel/visitors/db2.rb
activerecord-jdbc-adapter-1.3.0 lib/arel/visitors/db2.rb
activerecord-jdbc-adapter-1.3.0.rc1 lib/arel/visitors/db2.rb