diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/arel/primitives/attribute.rb | 14 | ||||
-rw-r--r-- | lib/arel/relations/compound.rb | 2 | ||||
-rw-r--r-- | lib/arel/relations/relation.rb | 2 |
3 files changed, 9 insertions, 9 deletions
diff --git a/lib/arel/primitives/attribute.rb b/lib/arel/primitives/attribute.rb index 78a519b35c..acc4d86a80 100644 --- a/lib/arel/primitives/attribute.rb +++ b/lib/arel/primitives/attribute.rb @@ -9,8 +9,8 @@ module Arel @relation, @name, @alias, @ancestor = relation, name, options[:alias], options[:ancestor] end - def alias_or_name - @alias || name + def named?(hypothetical_name) + (@alias || name).to_s == hypothetical_name.to_s end def aggregation? @@ -57,12 +57,12 @@ module Arel include Transformations module Congruence - def self.included(klass) - klass.hash_on :name - end - + # def self.included(klass) + # klass.hash_on :name + # end + # def history - [self] + (ancestor ? [ancestor, ancestor.history].flatten : []) + @history ||= [self] + (ancestor ? [ancestor, ancestor.history].flatten : []) end def match?(other) diff --git a/lib/arel/relations/compound.rb b/lib/arel/relations/compound.rb index 7b6f3a46f8..663711760c 100644 --- a/lib/arel/relations/compound.rb +++ b/lib/arel/relations/compound.rb @@ -8,7 +8,7 @@ module Arel :to => :relation def attributes - relation.attributes.collect { |a| a.bind(self) } + @attributes ||= relation.attributes.collect { |a| a.bind(self) } end end end
\ No newline at end of file diff --git a/lib/arel/relations/relation.rb b/lib/arel/relations/relation.rb index 4653323514..b2f811cea2 100644 --- a/lib/arel/relations/relation.rb +++ b/lib/arel/relations/relation.rb @@ -136,7 +136,7 @@ module Arel end def find_attribute_matching_name(name) - attributes.detect { |a| a.alias_or_name.to_s == name.to_s } + attributes.detect { |a| a.named?(name) } end # TESTME - added relation_for(x)[x] because of AR |