diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-10-21 16:49:21 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-10-21 16:49:21 -0700 |
commit | d8b09f3866defcd1bc97717fcc1bbfe9f643bd8c (patch) | |
tree | faade0dae95ebc78dda2d22d515f8a58c32bbb4a /activerecord/test | |
parent | 79d01a8f16e20c556a086a2f07e3ccb4400f9819 (diff) | |
parent | f092be821db4a2e8f142e8f0b9d08e497ccf2eb2 (diff) | |
download | rails-d8b09f3866defcd1bc97717fcc1bbfe9f643bd8c.tar.gz rails-d8b09f3866defcd1bc97717fcc1bbfe9f643bd8c.tar.bz2 rails-d8b09f3866defcd1bc97717fcc1bbfe9f643bd8c.zip |
Merge pull request #3400 from greinacker/sqlite-decimal
sqlite3 adapter drops :decimal columns precision & scale when migration tries to alter them
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/migration_test.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb index b3f1785f44..49944eced9 100644 --- a/activerecord/test/cases/migration_test.rb +++ b/activerecord/test/cases/migration_test.rb @@ -518,6 +518,42 @@ if ActiveRecord::Base.connection.supports_migrations? assert_equal 7, wealth_column.scale end + # Test SQLite adapter specifically for decimal types with precision and scale + # attributes, since these need to be maintained in schema but aren't actually + # used in SQLite itself + if current_adapter?(:SQLite3Adapter) + def test_change_column_with_new_precision_and_scale + Person.delete_all + Person.connection.add_column 'people', 'wealth', :decimal, :precision => 9, :scale => 7 + Person.reset_column_information + + Person.connection.change_column 'people', 'wealth', :decimal, :precision => 12, :scale => 8 + Person.reset_column_information + + wealth_column = Person.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 + Person.delete_all + Person.connection.add_column 'people', 'last_name', :string + Person.connection.add_column 'people', 'wealth', :decimal, :precision => 9, :scale => 7 + Person.reset_column_information + + wealth_column = Person.columns_hash['wealth'] + assert_equal 9, wealth_column.precision + assert_equal 7, wealth_column.scale + + Person.connection.change_column 'people', 'last_name', :string, :null => false + Person.reset_column_information + + wealth_column = Person.columns_hash['wealth'] + assert_equal 9, wealth_column.precision + assert_equal 7, wealth_column.scale + end + end + def test_native_types Person.delete_all Person.connection.add_column "people", "last_name", :string |