Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 8627

Show
Ignore:
Timestamp:
01/11/08 19:54:19 (7 months ago)
Author:
rick
Message:

Fix issue where Table#references doesn't pass a :null option to a *_type attribute for polymorphic associations. Closes #10753 [railsjitsu]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activerecord/CHANGELOG

    r8594 r8627  
    11*SVN* 
     2 
     3* Fix issue where Table#references doesn't pass a :null option to a *_type attribute for polymorphic associations.  Closes #10753 [railsjitsu] 
    24 
    35* Fixtures: removed support for the ancient pre-YAML file format.  #10736 [John Barnette] 
  • trunk/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb

    r8540 r8627  
    454454        args.each do |col| 
    455455          column("#{col}_id", :integer, options) 
    456           unless polymorphic.nil? 
    457             column("#{col}_type", :string, polymorphic.is_a?(Hash) ? polymorphic : {}) 
    458           end 
     456          column("#{col}_type", :string, polymorphic.is_a?(Hash) ? polymorphic : options) unless polymorphic.nil? 
    459457        end 
    460458      end 
  • trunk/activerecord/test/migration_test.rb

    r8570 r8627  
    926926      end 
    927927       
     928      def test_references_column_type_with_polymorphic_and_options_null_is_false_adds_table_flag 
     929        with_new_table do |t| 
     930          t.expects(:column).with('taggable_type', :string, {:null => false}) 
     931          t.expects(:column).with('taggable_id', :integer, {:null => false}) 
     932          t.references :taggable, :polymorphic => true, :null => false 
     933        end 
     934      end 
     935       
    928936      def test_belongs_to_works_like_references 
    929937        with_new_table do |t|