aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/migration_test.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2007-01-15 00:34:43 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2007-01-15 00:34:43 +0000
commite3103441114b1c5e7b67b71efa9c0b44e03645e6 (patch)
tree54bfe03ea0ef7637367bfb04e0200f939d9594cd /activerecord/test/migration_test.rb
parent9ccb12a3dda123942def21834eedb761299f67b9 (diff)
downloadrails-e3103441114b1c5e7b67b71efa9c0b44e03645e6.tar.gz
rails-e3103441114b1c5e7b67b71efa9c0b44e03645e6.tar.bz2
rails-e3103441114b1c5e7b67b71efa9c0b44e03645e6.zip
Oracle: create_table takes a :sequence_name option to override the 'tablename_seq' default. Closes #7000.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5933 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test/migration_test.rb')
-rw-r--r--activerecord/test/migration_test.rb39
1 files changed, 38 insertions, 1 deletions
diff --git a/activerecord/test/migration_test.rb b/activerecord/test/migration_test.rb
index ce79ffc80e..355c459818 100644
--- a/activerecord/test/migration_test.rb
+++ b/activerecord/test/migration_test.rb
@@ -700,6 +700,43 @@ if ActiveRecord::Base.connection.supports_migrations?
assert_equal 2, ActiveRecord::Migrator.current_version
end
-
+ def test_create_table_with_custom_sequence_name
+ return unless current_adapter? :OracleAdapter
+
+ # table name is 29 chars, the standard sequence name will
+ # be 33 chars and fail
+ assert_raises(ActiveRecord::StatementInvalid) do
+ begin
+ Person.connection.create_table :table_with_name_thats_just_ok do |t|
+ t.column :foo, :string, :null => false
+ end
+ ensure
+ Person.connection.drop_table :table_with_name_thats_just_ok rescue nil
+ end
+ end
+
+ # should be all good w/ a custom sequence name
+ assert_nothing_raised do
+ begin
+ Person.connection.create_table :table_with_name_thats_just_ok,
+ :sequence_name => 'suitably_short_seq' do |t|
+ t.column :foo, :string, :null => false
+ end
+
+ Person.connection.execute("select suitably_short_seq.nextval from dual")
+
+ ensure
+ Person.connection.drop_table :table_with_name_thats_just_ok,
+ :sequence_name => 'suitably_short_seq' rescue nil
+ end
+ end
+
+ # confirm the custom sequence got dropped
+ assert_raises(ActiveRecord::StatementInvalid) do
+ Person.connection.execute("select suitably_short_seq.nextval from dual")
+ end
+ end
+
end
end
+