aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/relations
diff options
context:
space:
mode:
Diffstat (limited to 'lib/arel/relations')
-rw-r--r--lib/arel/relations/compound.rb4
-rw-r--r--lib/arel/relations/recursion.rb10
-rw-r--r--lib/arel/relations/relation.rb2
3 files changed, 15 insertions, 1 deletions
diff --git a/lib/arel/relations/compound.rb b/lib/arel/relations/compound.rb
index 1459c163cf..6f230c3f57 100644
--- a/lib/arel/relations/compound.rb
+++ b/lib/arel/relations/compound.rb
@@ -11,6 +11,10 @@ module Arel
@attributes ||= relation.attributes.collect { |a| a.bind(self) }
end
+ def selects
+ @selects ||= relation.selects.collect { |s| s.bind(self) }
+ end
+
# XXX
def relation_for(attribute)
join? && relation.relation_for(attribute) || self[attribute] && self
diff --git a/lib/arel/relations/recursion.rb b/lib/arel/relations/recursion.rb
index fa4d9969c9..ea8109d87d 100644
--- a/lib/arel/relations/recursion.rb
+++ b/lib/arel/relations/recursion.rb
@@ -9,9 +9,19 @@ module Arel
formatter.table self
end
+ def root?
+ true
+ end
+
def relation_for(attribute)
self[attribute] && self
end
end
end
+
+ class Relation
+ def root?
+ false
+ end
+ end
end \ No newline at end of file
diff --git a/lib/arel/relations/relation.rb b/lib/arel/relations/relation.rb
index 884b743f20..25dc75e8ea 100644
--- a/lib/arel/relations/relation.rb
+++ b/lib/arel/relations/relation.rb
@@ -138,7 +138,7 @@ module Arel
# TESTME - added original_attribute because of AR
def find_attribute_matching_attribute(attribute)
attributes.select { |a| a.match?(attribute) }.max do |a1, a2|
- (attribute / a1.original_attribute) <=> (attribute / a2.original_attribute)
+ (attribute / a1.root) <=> (attribute / a2.root)
end
end
end