Sha256: dc5ceaf33d633e1632f35a06d77a76a350a8514aed64ba754ab16058adedfbae

Contents?: true

Size: 1.36 KB

Versions: 2

Compression:

Stored size: 1.36 KB

Contents

# rubocop:disable Naming/MethodName
# rubocop:disable Naming/UncommunicativeMethodParamName
# rubocop:disable Metrics/AbcSize

module Arel
  module Nodes
    class SelectCore < Arel::Nodes::Node
      attr_accessor :into
    end
  end

  module Visitors
    class ToSql
      def visit_Arel_Nodes_SelectCore(o, collector)
        collector << 'SELECT'

        collector = maybe_visit o.top, collector

        collector = maybe_visit o.set_quantifier, collector

        collect_nodes_for o.projections, collector, SPACE

        maybe_visit o.into, collector

        if o.source && !o.source.empty?
          collector << ' FROM '
          collector = visit o.source, collector
        end

        collect_nodes_for o.wheres, collector, WHERE, AND
        collect_nodes_for o.groups, collector, GROUP_BY
        unless o.havings.empty?
          collector << ' HAVING '
          inject_join o.havings, collector, AND
        end
        collect_nodes_for o.windows, collector, WINDOW

        collector
      end
    end

    class Dot
      module SelectCoreExtension
        def visit_Arel_Nodes_SelectCore(o)
          super

          visit_edge o, 'into'
          visit_edge o, 'top'
        end
      end

      prepend SelectCoreExtension
    end
  end
end

# rubocop:enable Metrics/AbcSize
# rubocop:enable Naming/MethodName
# rubocop:enable Naming/UncommunicativeMethodParamName

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
arel_toolkit-0.4.2 lib/arel/extensions/select_core.rb
arel_toolkit-0.4.1 lib/arel/extensions/select_core.rb