Sha256: 3668e1e2113d6e83f66bb299d6cab84cc7995357ad7b9f664618e229341e79e6

Contents?: true

Size: 636 Bytes

Versions: 17

Compression:

Stored size: 636 Bytes

Contents

require 'arel/visitors/compat'

module Arel
  module Visitors
    class Firebird < Arel::Visitors::ToSql
      def visit_Arel_Nodes_SelectStatement o
        lim_off = [
          ("FIRST #{visit(o.limit.expr)}" if o.limit),
          ("SKIP #{visit(o.offset.expr)}" if o.offset)
        ].compact.join(' ').strip

        sql = [
         o.cores.map { |x| visit_Arel_Nodes_SelectCore x }.join,
         ("ORDER BY #{o.orders.map { |x| visit x }.join(', ')}" unless o.orders.empty?),
        ].compact.join ' '

        sql.sub!(/\A(\s*SELECT\s)/i, '\&' + lim_off + ' ') unless lim_off.empty?

        sql
      end

    end
  end
end

Version data entries

17 entries across 17 versions & 4 rubygems

Version Path
activerecord-jdbc-adapter-1.2.9.1 lib/arel/visitors/firebird.rb
activerecord-jdbc-adapter-1.3.0.beta2 lib/arel/visitors/firebird.rb
cmoran92-activerecord-jdbc-adapter-1.2.1.2 lib/arel/visitors/firebird.rb
activerecord-jdbc-adapter-1.3.0.beta1 lib/arel/visitors/firebird.rb
activerecord-jdbc-adapter-1.2.9 lib/arel/visitors/firebird.rb
activerecord-jdbc-adapter-1.2.8 lib/arel/visitors/firebird.rb
activerecord-jdbc-adapter-1.2.5 lib/arel/visitors/firebird.rb
tgbyte-activerecord-jdbc-adapter-1.2.2.5 lib/arel/visitors/firebird.rb
tgbyte-activerecord-jdbc-adapter-1.2.2.4 lib/arel/visitors/firebird.rb
tgbyte-activerecord-jdbc-adapter-1.2.2.3 lib/arel/visitors/firebird.rb
tgbyte-activerecord-jdbc-adapter-1.2.2.2 lib/arel/visitors/firebird.rb
activerecord-jdbc-adapter-1.2.2.1 lib/arel/visitors/firebird.rb
activerecord-jdbc-adapter-onsite-1.2.2 lib/arel/visitors/firebird.rb
cmoran92-activerecord-jdbc-adapter-1.2.1.1 lib/arel/visitors/firebird.rb
activerecord-jdbc-adapter-1.2.2 lib/arel/visitors/firebird.rb
cmoran92-activerecord-jdbc-adapter-1.2.1 lib/arel/visitors/firebird.rb
activerecord-jdbc-adapter-1.2.1 lib/arel/visitors/firebird.rb