blob: 8cf7a7cdad1d63d8b154012b1aa69385777ca248 (
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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
module Arel
class Action < Compound
def == other
super || self.class === other && @relation == other.relation
end
end
class Deletion < Action
def call
engine.delete(self)
end
def to_sql
compiler.delete_sql
end
end
class Insert < Action
attr_reader :record
def initialize(relation, record)
super(relation)
@record = record.bind(relation)
end
def call
engine.create(self)
end
def == other
super && @record == other.record
end
def eval
unoperated_rows + [Row.new(self, record.values.collect(&:value))]
end
def to_sql(include_returning = true)
compiler.insert_sql(include_returning)
end
end
class Update < Insert
alias :assignments :record
def call
engine.update(self)
end
def to_sql
compiler.update_sql
end
end
end
|