blob: be21119bc95f591d0547f251d7ef6e5cd7480101 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
module Arel
class Join < Relation
def table_sql(formatter = Sql::TableReference.new(self))
relation1.externalize.table_sql(formatter)
end
def joins(environment, formatter = Sql::TableReference.new(environment))
@joins ||= begin
this_join = [
join_sql,
relation2.externalize.table_sql(formatter),
("ON" unless predicates.blank?),
(ons + relation2.externalize.wheres).collect { |p| p.bind(environment).to_sql(Sql::WhereClause.new(environment)) }.join(' AND ')
].compact.join(" ")
[relation1.joins(environment), this_join, relation2.joins(environment)].compact.join(" ")
end
end
end
end
|