blob: 0fcf523efe27f8250675203bd0b0426390f21e2b (
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
24
|
module ActiveRelation
class Deletion < Writing
def initialize(relation)
@relation = relation
end
def to_sql(strategy = nil)
[
"DELETE",
"FROM #{table_sql}",
("WHERE #{selects.collect(&:to_sql).join('\n\tAND ')}" unless selects.blank?)
].compact.join("\n")
end
def call(connection = engine.connection)
connection.delete(to_sql)
end
def ==(other)
self.class == other.class and
relation == other.relation
end
end
end
|