Sha256: 15a0dcd7b5a8d45ee96aea9224b1c7d4301358e19d3e3f5cfd43fe02327537e5

Contents?: true

Size: 660 Bytes

Versions: 2

Compression:

Stored size: 660 Bytes

Contents

module Arel
  module Visitors
    class RubyFB_15Compat < Arel::Visitors::ToSql
    	Arel::Visitors::VISITORS['rubyfb'] = Arel::Visitors::RubyFB_15Compat
    private
      def visit_Arel_Nodes_Limit o
      end

      def visit_Arel_Nodes_Offset o
      end
      
      def visit_Arel_Nodes_SelectStatement o
      	super.tap do |s|
      	  if o.limit || o.offset  
      	    s.gsub!(/^\s*select/i, "SELECT #{fb_limit(o.limit)} #{fb_offset(o.offset)} ")
      	  end
      	end
      end

      def fb_limit limit
      	"first #{limit.expr}" if limit
      end

      def fb_offset offset
      	"skip #{offset.expr}" if offset
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rubyfb-0.6.1 lib/arel/visitors/rubyfb_15compat.rb
rubyfb-0.6 lib/arel/visitors/rubyfb_15compat.rb