blob: df457686ccef3527035eccd274e0ee2e53263af0 (
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
module Arel
class Join < Relation
attributes :relation1, :relation2, :predicates
deriving :==
delegate :name, :to => :relation1
def initialize(relation1, relation2 = Nil.instance, *predicates)
@relation1, @relation2, @predicates = relation1, relation2, predicates
end
def hash
@hash ||= :relation1.hash
end
def eql?(other)
self == other
end
def attributes
@attributes ||= (relation1.externalize.attributes +
relation2.externalize.attributes).collect { |a| a.bind(self) }
end
def wheres
# TESTME bind to self?
relation1.externalize.wheres
end
def ons
@ons ||= @predicates.collect { |p| p.bind(self) }
end
# TESTME
def externalizable?
relation1.externalizable? or relation2.externalizable?
end
def join?
true
end
def engine
relation1.engine != relation2.engine ? Memory::Engine.new : relation1.engine
end
end
class InnerJoin < Join; end
class OuterJoin < Join; end
class StringJoin < Join
def externalizable?
relation1.externalizable?
end
def attributes
relation1.externalize.attributes
end
def engine
relation1.engine
end
end
class Relation
def join?
false
end
end
end
|