From be764d2c9ce1c8f980f2cf3bf021bdbd5d05f605 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 5 Mar 2013 14:52:08 -0800 Subject: [PATCH] stop calling to_sym when building arel nodes --- activerecord/lib/active_record/base.rb | 2 +- activerecord/lib/active_record/reflection.rb | 2 +- .../lib/active_support/core_ext/class/inheritable_attributes.rb | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index c11b702..894ca6b 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -2307,7 +2307,7 @@ module ActiveRecord #:nodoc: def expand_hash_conditions_for_aggregates(attrs) expanded_attrs = {} attrs.each do |attr, value| - unless (aggregation = reflect_on_aggregation(attr.to_sym)).nil? + unless (aggregation = reflect_on_aggregation(attr)).nil? mapping = aggregate_mapping(aggregation) mapping.each do |field_attr, aggregate_attr| if mapping.size == 1 && !value.respond_to?(aggregate_attr) diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb index 13bcb8b..a07d442 100644 --- a/activerecord/lib/active_record/reflection.rb +++ b/activerecord/lib/active_record/reflection.rb @@ -18,7 +18,7 @@ module ActiveRecord when :composed_of reflection = AggregateReflection.new(macro, name, options, active_record) end - write_inheritable_hash :reflections, name => reflection + write_inheritable_hiwa :reflections, name => reflection reflection end diff --git a/activesupport/lib/active_support/core_ext/class/inheritable_attributes.rb b/activesupport/lib/active_support/core_ext/class/inheritable_attributes.rb index 1794afe..d86eab8 100644 --- a/activesupport/lib/active_support/core_ext/class/inheritable_attributes.rb +++ b/activesupport/lib/active_support/core_ext/class/inheritable_attributes.rb @@ -109,6 +109,11 @@ class Class # :nodoc: write_inheritable_attribute(key, read_inheritable_attribute(key).merge(hash)) end + def write_inheritable_hiwa(key, hash) + write_inheritable_attribute(key, {}.with_indifferent_access) if read_inheritable_attribute(key).nil? + write_inheritable_attribute(key, read_inheritable_attribute(key).merge(hash)) + end + def read_inheritable_attribute(key) inheritable_attributes[key] end -- 1.8.1.1