blob: d05bd9cdc821d4e91d976de138d7b6c8ba00f299 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
module Arel
class Insert < Compound
attributes :relation, :record
deriving :==
def initialize(relation, record)
@relation, @record = relation, record.bind(relation)
end
def to_sql(formatter = nil)
[
"INSERT",
"INTO #{table_sql}",
"(#{record.keys.map { |key| engine.quote_column_name(key.name) }.join(', ')})",
"VALUES (#{record.map { |key, value| key.format(value) }.join(', ')})"
].join("\n")
end
def call
engine.create(self)
end
end
end
|