提交 59c218ea 编写于 作者: R Ryuta Kamizono

Remove unnecessary `assert_valid_default`

This was added at c7c3f73f but it never raised because MySQL cannot
create text/blob columns with a default value.
上级 6da5f6b4
......@@ -6,7 +6,6 @@ class Column < ConnectionAdapters::Column # :nodoc:
def initialize(*)
super
assert_valid_default
extract_default
end
......@@ -38,12 +37,6 @@ def extract_default
@default = null || strict ? nil : ''
end
end
def assert_valid_default
if blob_or_text_column? && default.present?
raise ArgumentError, "#{type} columns cannot have a default value: #{default.inspect}"
end
end
end
end
end
......
......@@ -60,15 +60,8 @@ def test_should_be_empty_string_default_for_mysql_binary_data_types
end
def test_should_not_set_default_for_blob_and_text_data_types
assert_raise ArgumentError do
MySQL::Column.new("title", "a", SqlTypeMetadata.new(sql_type: "blob"))
end
text_type = MySQL::TypeMetadata.new(
SqlTypeMetadata.new(type: :text))
assert_raise ArgumentError do
MySQL::Column.new("title", "Hello", text_type)
end
text_column = MySQL::Column.new("title", nil, text_type)
assert_equal nil, text_column.default
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册