提交 1aad9f6b 编写于 作者: R Ryuta Kamizono

Both reference id and type should be `NOT NULL` if `null: false` is specified

This is a regression due to #28282.

Fixes #29136.
上级 b9b4fa91
......@@ -146,7 +146,7 @@ def as_options(value)
end
def polymorphic_options
as_options(polymorphic)
as_options(polymorphic).merge(null: options[:null])
end
def index_options
......
......@@ -50,6 +50,14 @@ def test_creates_reference_type_column_with_default
assert column_exists?(table_name, :taggable_type, :string, default: "Photo")
end
def test_creates_reference_type_column_with_not_null
connection.create_table table_name, force: true do |t|
t.references :taggable, null: false, polymorphic: true
end
assert column_exists?(table_name, :taggable_id, :integer, null: false)
assert column_exists?(table_name, :taggable_type, :string, null: false)
end
def test_does_not_share_options_with_reference_type_column
add_reference table_name, :taggable, type: :integer, limit: 2, polymorphic: true
assert column_exists?(table_name, :taggable_id, :integer, limit: 2)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册