aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/algebra
diff options
context:
space:
mode:
authorEmilio Tagua <miloops@gmail.com>2010-03-10 18:16:07 -0300
committerEmilio Tagua <miloops@gmail.com>2010-03-10 18:16:07 -0300
commitb706f690b611d647aae15a85caa19d167814ae3c (patch)
tree05a17b2e937f894ea03f3fff535fd62cbc31a025 /lib/arel/algebra
parentc03d4bb8e4acac95961a1a9eb9578fa33a47da66 (diff)
downloadrails-b706f690b611d647aae15a85caa19d167814ae3c.tar.gz
rails-b706f690b611d647aae15a85caa19d167814ae3c.tar.bz2
rails-b706f690b611d647aae15a85caa19d167814ae3c.zip
Arel doesn't has to know if a table or column exists.
Diffstat (limited to 'lib/arel/algebra')
-rw-r--r--lib/arel/algebra/relations/relation.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/arel/algebra/relations/relation.rb b/lib/arel/algebra/relations/relation.rb
index e848c8aa1c..4cd3f8e109 100644
--- a/lib/arel/algebra/relations/relation.rb
+++ b/lib/arel/algebra/relations/relation.rb
@@ -84,7 +84,8 @@ module Arel
module AttributeAccessable
def [](index)
- case index
+ @cached_attributes ||= {}
+ @cached_attributes[index] ||= case index
when Symbol, String
find_attribute_matching_name(index)
when Attribute, Expression
@@ -96,7 +97,7 @@ module Arel
end
def find_attribute_matching_name(name)
- attributes.detect { |a| a.named?(name) }
+ attributes.detect { |a| a.named?(name) } || Attribute.new(self, name)
end
def find_attribute_matching_attribute(attribute)