aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/engines/sql/relations/writes/insert.rb
blob: aac9c87a5bb6a9a03aed634ea50a58f4b6cd6ca6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
module Arel
  class Insert < Compound
    def to_sql(formatter = nil)
      [
        "INSERT",
        "INTO #{table_sql}",
        "(#{record.keys.collect { |key| engine.quote_column_name(key.name) }.join(', ')})",
        "VALUES (#{record.collect { |key, value| key.format(value) }.join(', ')})"
      ].join("\n")
    end
  end
end