blob: b1ff3bef278badd2355edb9ed52e04bb9e76b312 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
module Arel
class Deletion < Compound
attributes :relation
deriving :initialize, :==
def to_sql(formatter = nil)
[
"DELETE",
"FROM #{table_sql}",
("WHERE #{wheres.collect(&:to_sql).join('\n\tAND ')}" unless wheres.blank? ),
("LIMIT #{taken}" unless taken.blank? ),
].compact.join("\n")
end
def call(connection = engine)
connection.delete(to_sql)
end
end
end
|