提交 c910fd82 编写于 作者: R Ryuta Kamizono 提交者: GitHub

Improve `migration/column_attributes_test.rb` (#25286)

* Test `test_unabstracted_database_dependent_types` for `PostgreSQLAdapter`
* Add `test_change_column_with_new_precision_and_scale` for `SQLite3Adapter`
 * This test case and comment was lost at 28bb02a7
上级 53524818
......@@ -45,11 +45,11 @@ def test_add_column_without_limit
assert_nil TestModel.columns_hash["description"].limit
end
if current_adapter?(:Mysql2Adapter)
if current_adapter?(:Mysql2Adapter, :PostgreSQLAdapter)
def test_unabstracted_database_dependent_types
add_column :test_models, :intelligence_quotient, :tinyint
add_column :test_models, :intelligence_quotient, :smallint
TestModel.reset_column_information
assert_match(/tinyint/, TestModel.columns_hash["intelligence_quotient"].sql_type)
assert_match(/smallint/, TestModel.columns_hash["intelligence_quotient"].sql_type)
end
end
......@@ -99,7 +99,21 @@ def test_add_column_with_precision_and_scale
assert_equal 7, wealth_column.scale
end
# Test SQLite3 adapter specifically for decimal types with precision and scale
# attributes, since these need to be maintained in schema but aren't actually
# used in SQLite3 itself
if current_adapter?(:SQLite3Adapter)
def test_change_column_with_new_precision_and_scale
connection.add_column "test_models", "wealth", :decimal, precision: 9, scale: 7
connection.change_column "test_models", "wealth", :decimal, precision: 12, scale: 8
TestModel.reset_column_information
wealth_column = TestModel.columns_hash["wealth"]
assert_equal 12, wealth_column.precision
assert_equal 8, wealth_column.scale
end
def test_change_column_preserve_other_column_precision_and_scale
connection.add_column "test_models", "last_name", :string
connection.add_column "test_models", "wealth", :decimal, precision: 9, scale: 7
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册