Parent

Included Modules

Files

Class Index [+]

Quicksearch

Arel::Join

Attributes

relation1[R]
relation2[R]
predicates[R]

Public Class Methods

new(relation1, relation2 = Nil.instance, *predicates) click to toggle source
    # File lib/arel/algebra/relations/operations/join.rb, line 7
 7:     def initialize(relation1, relation2 = Nil.instance, *predicates)
 8:       @relation1  = relation1
 9:       @relation2  = relation2
10:       @predicates = predicates
11:       @attributes = nil
12:     end

Public Instance Methods

attributes() click to toggle source
    # File lib/arel/algebra/relations/operations/join.rb, line 18
18:     def attributes
19:       @attributes ||= (relation1.externalize.attributes | relation2.externalize.attributes).bind(self)
20:     end
engine() click to toggle source
    # File lib/arel/algebra/relations/operations/join.rb, line 40
40:     def engine
41:       relation1.engine != relation2.engine ? Memory::Engine.new : relation1.engine
42:     end
eval() click to toggle source
    # File lib/arel/algebra/relations/operations/join.rb, line 60
60:     def eval
61:       result = []
62:       relation1.call.each do |row1|
63:         relation2.call.each do |row2|
64:           combined_row = row1.combine(row2, self)
65:           if predicates.all? { |p| p.eval(combined_row) }
66:             result << combined_row
67:           end
68:         end
69:       end
70:       result
71:     end
externalizable?() click to toggle source

TESTME

    # File lib/arel/algebra/relations/operations/join.rb, line 32
32:     def externalizable?
33:       relation1.externalizable? or relation2.externalizable?
34:     end
join?() click to toggle source
    # File lib/arel/algebra/relations/operations/join.rb, line 36
36:     def join?
37:       true
38:     end
joins(environment, formatter = Sql::TableReference.new(environment)) click to toggle source
    # File lib/arel/algebra/relations/operations/join.rb, line 48
48:     def joins(environment, formatter = Sql::TableReference.new(environment))
49:       @joins ||= begin
50:         this_join = [
51:           join_sql,
52:           relation2.externalize.table_sql(formatter),
53:           ("ON" unless predicates.blank?),
54:           (ons + relation2.externalize.wheres).collect { |p| p.bind(environment.relation).to_sql(Sql::WhereClause.new(environment)) }.join(' AND ')
55:         ].compact.join(" ")
56:         [relation1.joins(environment), this_join, relation2.joins(environment)].compact.join(" ")
57:       end
58:     end
name() click to toggle source
    # File lib/arel/algebra/relations/operations/join.rb, line 14
14:     def name
15:       relation1.name
16:     end
ons() click to toggle source
    # File lib/arel/algebra/relations/operations/join.rb, line 27
27:     def ons
28:       @ons ||= @predicates.collect { |p| p.bind(self) }
29:     end
table_sql(formatter = Sql::TableReference.new(self)) click to toggle source
    # File lib/arel/algebra/relations/operations/join.rb, line 44
44:     def table_sql(formatter = Sql::TableReference.new(self))
45:       relation1.externalize.table_sql(formatter)
46:     end
to_sql(formatter = nil) click to toggle source
    # File lib/arel/algebra/relations/operations/join.rb, line 73
73:     def to_sql(formatter = nil)
74:       compiler.select_sql
75:     end
wheres() click to toggle source
    # File lib/arel/algebra/relations/operations/join.rb, line 22
22:     def wheres
23:       # TESTME bind to self?
24:       relation1.externalize.wheres
25:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.