Sha256: ef631838d27565f886066190e59702e062a41896477ef27b06f8141aa37f999b

Contents?: true

Size: 1.8 KB

Versions: 36

Compression:

Stored size: 1.8 KB

Contents

# frozen_string_literal: true

module Arel # :nodoc: all
  module Visitors
    class Informix < Arel::Visitors::ToSql
      private
        def visit_Arel_Nodes_SelectStatement(o, collector)
          collector << "SELECT "
          collector = maybe_visit o.offset, collector
          collector = maybe_visit o.limit, collector
          collector = o.cores.inject(collector) { |c, x|
            visit_Arel_Nodes_SelectCore x, c
          }
          if o.orders.any?
            collector << "ORDER BY "
            collector = inject_join o.orders, collector, ", "
          end
          maybe_visit o.lock, collector
        end

        def visit_Arel_Nodes_SelectCore(o, collector)
          collector = inject_join o.projections, collector, ", "
          if o.source && !o.source.empty?
            collector << " FROM "
            collector = visit o.source, collector
          end

          if o.wheres.any?
            collector << " WHERE "
            collector = inject_join o.wheres, collector, " AND "
          end

          if o.groups.any?
            collector << "GROUP BY "
            collector = inject_join o.groups, collector, ", "
          end

          if o.havings.any?
            collector << " HAVING "
            collector = inject_join o.havings, collector, " AND "
          end
          collector
        end

        def visit_Arel_Nodes_OptimizerHints(o, collector)
          hints = o.expr.map { |v| sanitize_as_sql_comment(v) }.join(", ")
          collector << "/*+ #{hints} */"
        end

        def visit_Arel_Nodes_Offset(o, collector)
          collector << "SKIP "
          visit o.expr, collector
        end

        def visit_Arel_Nodes_Limit(o, collector)
          collector << "FIRST "
          visit o.expr, collector
          collector << " "
        end
    end
  end
end

Version data entries

36 entries across 36 versions & 4 rubygems

Version Path
activerecord-6.0.6.1 lib/arel/visitors/informix.rb
activerecord-6.0.6 lib/arel/visitors/informix.rb
activerecord-6.0.5.1 lib/arel/visitors/informix.rb
activerecord-6.0.5 lib/arel/visitors/informix.rb
activerecord-6.0.4.8 lib/arel/visitors/informix.rb
activerecord-6.0.4.7 lib/arel/visitors/informix.rb
activerecord-6.0.4.6 lib/arel/visitors/informix.rb
activerecord-6.0.4.5 lib/arel/visitors/informix.rb
activerecord-6.0.4.4 lib/arel/visitors/informix.rb
activerecord-6.0.4.3 lib/arel/visitors/informix.rb
activerecord-6.0.4.2 lib/arel/visitors/informix.rb
activerecord-6.0.4.1 lib/arel/visitors/informix.rb
activerecord-6.0.4 lib/arel/visitors/informix.rb
activerecord-6.0.3.7 lib/arel/visitors/informix.rb
activerecord-6.0.3.6 lib/arel/visitors/informix.rb
activerecord-6.0.3.5 lib/arel/visitors/informix.rb
activerecord-6.0.3.4 lib/arel/visitors/informix.rb
activerecord-6.0.3.3 lib/arel/visitors/informix.rb
activerecord-6.0.3.2 lib/arel/visitors/informix.rb
activerecord-6.0.3.1 lib/arel/visitors/informix.rb