diff options
Diffstat (limited to 'lib/arel/relations')
-rw-r--r-- | lib/arel/relations/join.rb | 8 | ||||
-rw-r--r-- | lib/arel/relations/recursion.rb | 2 | ||||
-rw-r--r-- | lib/arel/relations/relation.rb | 3 |
3 files changed, 6 insertions, 7 deletions
diff --git a/lib/arel/relations/join.rb b/lib/arel/relations/join.rb index c1c3150629..b3452968e4 100644 --- a/lib/arel/relations/join.rb +++ b/lib/arel/relations/join.rb @@ -44,15 +44,15 @@ module Arel end def relation_for(attribute) - [externalize(relation1), externalize(relation2)].max do |r1, r2| - o1, o2 = r1.relation_for(attribute), r2.relation_for(attribute) - a1, a2 = o1 && o1[attribute], o2 && o2[attribute] + [externalize(relation1).relation_for(attribute), externalize(relation2).relation_for(attribute)].max do |r1, r2| + a1, a2 = r1 && r1[attribute], r2 && r2[attribute] attribute / a1 <=> attribute / a2 - end.relation_for(attribute) + end end private + # FIXME - make instance method def externalize(relation) relation.aggregation?? Aggregation.new(relation) : relation end diff --git a/lib/arel/relations/recursion.rb b/lib/arel/relations/recursion.rb index 2c6024dc30..90976c702b 100644 --- a/lib/arel/relations/recursion.rb +++ b/lib/arel/relations/recursion.rb @@ -6,7 +6,7 @@ module Arel end def relation_for(attribute) - self[attribute] and self + self end def table_sql(formatter = Sql::TableReference.new(self)) diff --git a/lib/arel/relations/relation.rb b/lib/arel/relations/relation.rb index b2f811cea2..db7d746c79 100644 --- a/lib/arel/relations/relation.rb +++ b/lib/arel/relations/relation.rb @@ -142,8 +142,7 @@ module Arel # TESTME - added relation_for(x)[x] because of AR def find_attribute_matching_attribute(attribute) attributes.select { |a| a.match?(attribute) }.max do |a1, a2| - # FIXME relation_for(a1)[a1] should be a1.original or something - (attribute / relation_for(a1)[a1]) <=> (attribute / relation_for(a2)[a2]) + (attribute / a1.original_attribute) <=> (attribute / a2.original_attribute) end end |