diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-10-29 18:40:49 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-10-29 18:40:49 +0000 |
commit | 68160b34854f6b886b3cf9fe3045af1d18128747 (patch) | |
tree | 873cc3c0e6d96c7f94f023385c823df237a9e79e /activerecord/test/migration_test.rb | |
parent | 14b60fc074d8a97379561003281df70053225e01 (diff) | |
download | rails-68160b34854f6b886b3cf9fe3045af1d18128747.tar.gz rails-68160b34854f6b886b3cf9fe3045af1d18128747.tar.bz2 rails-68160b34854f6b886b3cf9fe3045af1d18128747.zip |
Added migration support for Oracle (closes #2647) [Michael Schoen]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2817 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test/migration_test.rb')
-rw-r--r-- | activerecord/test/migration_test.rb | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/activerecord/test/migration_test.rb b/activerecord/test/migration_test.rb index be1dfef7b0..56d5e12090 100644 --- a/activerecord/test/migration_test.rb +++ b/activerecord/test/migration_test.rb @@ -84,8 +84,14 @@ if ActiveRecord::Base.connection.supports_migrations? four = columns.detect { |c| c.name == "four" } assert_equal "hello", one.default - assert_equal true, two.default - assert_equal false, three.default + if current_adapter?(:OCIAdapter) + # Oracle doesn't support native booleans + assert_equal true, two.default == 1 + assert_equal false, three.default != 0 + else + assert_equal true, two.default + assert_equal false, three.default + end assert_equal 1, four.default ensure @@ -147,8 +153,8 @@ if ActiveRecord::Base.connection.supports_migrations? assert_equal Fixnum, bob.age.class assert_equal Time, bob.birthday.class - if current_adapter?(:SQLServerAdapter) - # SQL Server doesn't differentiate between date/time + if current_adapter?(:SQLServerAdapter) or current_adapter?(:OCIAdapter) + # SQL Server and Oracle don't differentiate between date/time assert_equal Time, bob.favorite_day.class else assert_equal Date, bob.favorite_day.class @@ -231,21 +237,26 @@ if ActiveRecord::Base.connection.supports_migrations? begin ActiveRecord::Base.connection.create_table :octopuses do |t| t.column :url, :string - end + end ActiveRecord::Base.connection.rename_table :octopuses, :octopi - + assert_nothing_raised do - ActiveRecord::Base.connection.execute "INSERT INTO octopi (url) VALUES ('http://www.foreverflying.com/octopus-black7.jpg')" + if current_adapter?(:OCIAdapter) + # Oracle requires the explicit sequence for the pk + ActiveRecord::Base.connection.execute "INSERT INTO octopi (id, url) VALUES (octopi_seq.nextval, 'http://www.foreverflying.com/octopus-black7.jpg')" + else + ActiveRecord::Base.connection.execute "INSERT INTO octopi (url) VALUES ('http://www.foreverflying.com/octopus-black7.jpg')" + end end assert_equal 'http://www.foreverflying.com/octopus-black7.jpg', ActiveRecord::Base.connection.select_value("SELECT url FROM octopi WHERE id=1") - + ensure ActiveRecord::Base.connection.drop_table :octopuses rescue nil ActiveRecord::Base.connection.drop_table :octopi rescue nil end end - + def test_change_column Person.connection.add_column "people", "bio", :string assert_nothing_raised { Person.connection.change_column "people", "bio", :text } @@ -398,4 +409,4 @@ if ActiveRecord::Base.connection.supports_migrations? Reminder.reset_table_name end end -end
\ No newline at end of file +end |