diff options
author | Jamis Buck <jamis@37signals.com> | 2005-07-30 10:16:21 +0000 |
---|---|---|
committer | Jamis Buck <jamis@37signals.com> | 2005-07-30 10:16:21 +0000 |
commit | da874a4af817ebeb9421934b2a4e4e0032b1234d (patch) | |
tree | 29b3e248526352bb6697298e876579a8ee374cb5 /activerecord/test | |
parent | 0ea1375d7526cd1bbd74947f292d13b83a7617e6 (diff) | |
download | rails-da874a4af817ebeb9421934b2a4e4e0032b1234d.tar.gz rails-da874a4af817ebeb9421934b2a4e4e0032b1234d.tar.bz2 rails-da874a4af817ebeb9421934b2a4e4e0032b1234d.zip |
Allow add_column and create_table to specify NOT NULL #1712 [emptysands@gmail.com]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1955 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/migration_test.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/activerecord/test/migration_test.rb b/activerecord/test/migration_test.rb index 60bdf90bf4..f98986cdfa 100644 --- a/activerecord/test/migration_test.rb +++ b/activerecord/test/migration_test.rb @@ -50,6 +50,31 @@ if ActiveRecord::Base.connection.supports_migrations? ensure Person.connection.drop_table :testings rescue nil end + + def test_create_table_with_not_null_column + Person.connection.create_table :testings do |t| + t.column :foo, :string, :null => false + end + + assert_raises(ActiveRecord::StatementInvalid) do + Person.connection.execute "insert into testings (foo) values (NULL)" + end + ensure + Person.connection.drop_table :testings rescue nil + end + + def test_add_column_not_null + Person.connection.create_table :testings do |t| + t.column :foo, :string + end + Person.connection.add_column :testings, :bar, :string, :null => false + + assert_raises(ActiveRecord::StatementInvalid) do + Person.connection.execute "insert into testings (foo, bar) values ('hello', NULL)" + end + ensure + Person.connection.drop_table :testings rescue nil + end def test_native_types Person.delete_all |