diff options
| -rw-r--r-- | activerecord/CHANGELOG | 2 | ||||
| -rw-r--r-- | activerecord/lib/active_record/reflection.rb | 6 | ||||
| -rwxr-xr-x | activerecord/test/fixtures/company.rb | 2 | ||||
| -rw-r--r-- | activerecord/test/reflection_test.rb | 4 | 
4 files changed, 10 insertions, 4 deletions
| diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index af0b44e3ce..d894dd9ee3 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -1,5 +1,7 @@  *SVN* +* Fixed that reflections would bleed across class boundaries in single-table inheritance setups #3796 [lars@pind.com] +  * Added calculations: Base.count, Base.average, Base.sum, Base.minimum, Base.maxmium, and the generic Base.calculate. All can be used with :group and :having. Calculations and statitics need no longer require custom SQL. #3958 [Rick Olson]. Examples:      Person.average :age diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb index 2f73300abf..774df46246 100644 --- a/activerecord/lib/active_record/reflection.rb +++ b/activerecord/lib/active_record/reflection.rb @@ -13,10 +13,12 @@ module ActiveRecord        def create_reflection(macro, name, options, active_record)          case macro            when :has_many, :belongs_to, :has_one, :has_and_belongs_to_many -            reflections[name] = AssociationReflection.new(macro, name, options, active_record) +            reflection = AssociationReflection.new(macro, name, options, active_record)            when :composed_of -            reflections[name] = AggregateReflection.new(macro, name, options, active_record) +            reflection = AggregateReflection.new(macro, name, options, active_record)          end +        write_inheritable_hash :reflections, name => reflection +        reflection        end        def reflections diff --git a/activerecord/test/fixtures/company.rb b/activerecord/test/fixtures/company.rb index d4a68900fe..5d53898802 100755 --- a/activerecord/test/fixtures/company.rb +++ b/activerecord/test/fixtures/company.rb @@ -3,6 +3,8 @@ class Company < ActiveRecord::Base    set_sequence_name :companies_nonstd_seq    validates_presence_of :name + +  has_one :dummy_account, :foreign_key => "firm_id", :class_name => "Account"  end diff --git a/activerecord/test/reflection_test.rb b/activerecord/test/reflection_test.rb index 6e5d7126f5..27cb40ee4d 100644 --- a/activerecord/test/reflection_test.rb +++ b/activerecord/test/reflection_test.rb @@ -128,9 +128,9 @@ class ReflectionTest < Test::Unit::TestCase    end    def test_reflection_of_all_associations -    assert_equal 12, Firm.reflect_on_all_associations.size +    assert_equal 13, Firm.reflect_on_all_associations.size      assert_equal 11, Firm.reflect_on_all_associations(:has_many).size -    assert_equal 1, Firm.reflect_on_all_associations(:has_one).size +    assert_equal 2, Firm.reflect_on_all_associations(:has_one).size      assert_equal 0, Firm.reflect_on_all_associations(:belongs_to).size    end | 
