Permalink
Browse files

Merge [8627] fix to stable.

git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/2-0-stable@8631 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
NZKoz committed Jan 12, 2008
1 parent 207473b commit 1752dccb34e6e76f53ca2d166db2039032cb9bcc
View
@@ -1,5 +1,7 @@
*SVN*
+* Fix issue where Table#references doesn't pass a :null option to a *_type attribute for polymorphic associations. Closes #10753 [railsjitsu]
+
* update_all ignores scoped :order and :limit, so post.comments.update_all doesn't try to include the comment order in the update statement. #10686 [Brendan Ribera]
* Added by parameter to increment, decrement, and their bang varieties so you can do player1.increment!(:points, 5) #10542 [Sam]
@@ -453,9 +453,7 @@ def references(*args)
polymorphic = options.delete(:polymorphic)
args.each do |col|
column("#{col}_id", :integer, options)
- unless polymorphic.nil?
- column("#{col}_type", :string, polymorphic.is_a?(Hash) ? polymorphic : {})
- end
+ column("#{col}_type", :string, polymorphic.is_a?(Hash) ? polymorphic : options) unless polymorphic.nil?
end
end
alias :belongs_to :references
@@ -925,6 +925,14 @@ def test_references_column_type_with_polymorphic_adds_type
end
end
+ def test_references_column_type_with_polymorphic_and_options_null_is_false_adds_table_flag
+ with_new_table do |t|
+ t.expects(:column).with('taggable_type', :string, {:null => false})
+ t.expects(:column).with('taggable_id', :integer, {:null => false})
+ t.references :taggable, :polymorphic => true, :null => false
+ end
+ end
+
def test_belongs_to_works_like_references
with_new_table do |t|
t.expects(:column).with('customer_id', :integer, {})

0 comments on commit 1752dcc

Please sign in to comment.