Sha256: 74476900f89e950e3d4dba63207860dc4a1939c1dbe703f24b2f85115ec95cc5

Contents?: true

Size: 645 Bytes

Versions: 1

Compression:

Stored size: 645 Bytes

Contents

module Arel
  module Visitors
    class SybaseJtds < Arel::Visitors::ToSql
      def visit_Arel_Nodes_SelectStatement o
        if o.offset
          sql = super  # if offset use the Java limit/offset parser
        else
          limit  = o.limit
          o.limit = nil
          sql = super

          if limit
            limit_and_no_offset sql, limit
          end
        end

        sql
      end

      def limit_and_no_offset sql, limit
        if sql =~ /DISTINCT /
          sql.gsub!(/DISTINCT /, "DISTINCT TOP #{limit} ")
        else
          sql.gsub!(/SELECT /, "SELECT TOP #{limit} ")
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ar-sybase-jdbc-adapter-0.0.2 lib/arel/visitors/sybase_jtds.rb