diff options
Diffstat (limited to 'lib/arel/algebra/attributes/attribute.rb')
-rw-r--r-- | lib/arel/algebra/attributes/attribute.rb | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/lib/arel/algebra/attributes/attribute.rb b/lib/arel/algebra/attributes/attribute.rb index 13781f47e0..2a4b274a96 100644 --- a/lib/arel/algebra/attributes/attribute.rb +++ b/lib/arel/algebra/attributes/attribute.rb @@ -3,13 +3,16 @@ require 'set' module Arel class TypecastError < StandardError ; end class Attribute - attr_reader :relation, :name, :alias, :ancestor + attr_reader :relation, :name, :alias, :ancestor, :hash def initialize(relation, name, options = {}) @relation = relation # this is actually a table (I think) @name = name @alias = options[:alias] @ancestor = options[:ancestor] + + # FIXME: I think we can remove this eventually + @hash = name.hash + root.relation.class.hash end def engine @@ -23,10 +26,10 @@ module Arel def == other super || Attribute === other && - @relation == other.relation && @name == other.name && @alias == other.alias && - @ancestor == other.ancestor + @ancestor == other.ancestor && + @relation == other.relation end alias :eql? :== @@ -43,10 +46,6 @@ module Arel row[self] end - def hash - @hash ||= name.hash + root.relation.hash - end - def as(aliaz = nil) Attribute.new(relation, name, :alias => aliaz, :ancestor => self) end |