From b06d351b701906efab737894be674c66561ec524 Mon Sep 17 00:00:00 2001 From: Nick Kallen Date: Fri, 16 May 2008 17:10:35 -0700 Subject: this is as close as it's been --- lib/arel/primitives/attribute.rb | 6 ++++++ lib/arel/relations/relation.rb | 3 +-- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'lib/arel') diff --git a/lib/arel/primitives/attribute.rb b/lib/arel/primitives/attribute.rb index 9fb47d56cf..1de2bf7cb0 100644 --- a/lib/arel/primitives/attribute.rb +++ b/lib/arel/primitives/attribute.rb @@ -39,6 +39,11 @@ module Arel def original_relation relation.relation_for(self) + # root.relation + end + + def original_attribute + original_relation[self] end module Transformations @@ -85,6 +90,7 @@ module Arel if other then (history & other.history).size.to_f / Set.new(history + other.history).size else 0 end + # 1 / (history.index(other) || -1) end end include Congruence diff --git a/lib/arel/relations/relation.rb b/lib/arel/relations/relation.rb index 25dc75e8ea..490f545637 100644 --- a/lib/arel/relations/relation.rb +++ b/lib/arel/relations/relation.rb @@ -135,10 +135,9 @@ module Arel attributes.detect { |a| a.named?(name) } end - # 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.root) <=> (attribute / a2.root) + (a1.original_attribute / attribute) <=> (a2.original_attribute / attribute) end end end -- cgit v1.2.3