Sha256: eeab4c68447c84de3fc9638ed51a0905fbafcf933d2723cc3d21497afab6d526

Contents?: true

Size: 1.53 KB

Versions: 4

Compression:

Stored size: 1.53 KB

Contents

# frozen_string_literal: true
module Arel
  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
        collector = 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_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

4 entries across 4 versions & 3 rubygems

Version Path
spiral_form-0.1.1 vendor/bundle/gems/arel-9.0.0/lib/arel/visitors/informix.rb
spiral_form-0.1.0 vendor/bundle/gems/arel-9.0.0/lib/arel/visitors/informix.rb
nullifyable-0.1.0 vendor/bundle/gems/arel-9.0.0/lib/arel/visitors/informix.rb
arel-9.0.0 lib/arel/visitors/informix.rb