Sha256: b94a6bd79d75e3cc97380813dd67f6df4d139ce74aa22f61077f82624002cab2

Contents?: true

Size: 817 Bytes

Versions: 1

Compression:

Stored size: 817 Bytes

Contents

module Archon
  module Visitors
    module ValuesList
      private

      def visit_Archon_Nodes_ValuesList o, collector
        collector << 'VALUES '

        len_a = o.expressions.length - 1
        o.expressions.each_with_index do |values, i|
          collector << '('
          len_b = values.length - 1
          values.each_with_index do |value, ii|
            case value
            when Arel::Nodes::SqlLiteral, Arel::Nodes::BindParam
              collector = visit value, collector
            else
              collector << quote(value).to_s
            end
            collector << Arel::Visitors::ToSql::COMMA unless ii == len_b
          end
          collector << ')'
          collector << Arel::Visitors::ToSql::COMMA unless i == len_a
        end

        collector
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
archon-0.0.4 lib/archon/visitors/values_list.rb