diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/arel/algebra/attributes/attribute.rb | 4 | ||||
-rw-r--r-- | lib/arel/algebra/relations/relation.rb | 8 |
2 files changed, 7 insertions, 5 deletions
diff --git a/lib/arel/algebra/attributes/attribute.rb b/lib/arel/algebra/attributes/attribute.rb index 50d79fa4b9..13781f47e0 100644 --- a/lib/arel/algebra/attributes/attribute.rb +++ b/lib/arel/algebra/attributes/attribute.rb @@ -29,6 +29,8 @@ module Arel @ancestor == other.ancestor end + alias :eql? :== + def named?(hypothetical_name) (@alias || name).to_s == hypothetical_name.to_s end @@ -41,8 +43,6 @@ module Arel row[self] end - alias :eql? :== - def hash @hash ||= name.hash + root.relation.hash end diff --git a/lib/arel/algebra/relations/relation.rb b/lib/arel/algebra/relations/relation.rb index 9cb38218c0..62d9bf177c 100644 --- a/lib/arel/algebra/relations/relation.rb +++ b/lib/arel/algebra/relations/relation.rb @@ -187,9 +187,11 @@ module Arel end def position_of(attribute) - (@position_of ||= Hash.new do |h, attribute| - h[attribute] = attributes.index(self[attribute]) - end)[attribute] + @position_of ||= {} + + return @position_of[attribute] if @position_of.key? attribute + + @position_of[attribute] = attributes.index(attributes[attribute]) end private |