aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/arel/algebra/relations/relation.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/arel/algebra/relations/relation.rb b/lib/arel/algebra/relations/relation.rb
index e2f9f12866..d51e24d088 100644
--- a/lib/arel/algebra/relations/relation.rb
+++ b/lib/arel/algebra/relations/relation.rb
@@ -206,10 +206,12 @@ module Arel
private
def matching_attributes(attribute)
- (@matching_attributes ||= attributes.inject({}) do |hash, a|
- (hash[a.is_a?(Value) ? a.value : a.root] ||= []) << a
- hash
- end)[attribute.root] || []
+ unless @matching_attributes
+ @matching_attributes = Hash[attributes.map do |a|
+ [a.root, a]
+ end]
+ end
+ [@matching_attributes[attribute.root]] || []
end
def has_attribute?(attribute)