Skip to content

Commit

Permalink
Oracle enhanced adapter now supports shortening of default generated …
Browse files Browse the repository at this point in the history
…index names, some additional tests now pass
  • Loading branch information
rsim committed Jun 4, 2010
1 parent 6356a48 commit f12f377
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions activerecord/test/cases/migration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,17 @@ def test_add_index

# Orcl nds shrt indx nms. Sybs 2.
# OpenBase does not have named indexes. You must specify a single column name
unless current_adapter?(:OracleAdapter, :SybaseAdapter, :OpenBaseAdapter)
unless current_adapter?(:SybaseAdapter, :OpenBaseAdapter)
assert_nothing_raised { Person.connection.add_index("people", ["last_name", "first_name"]) }
assert_nothing_raised { Person.connection.remove_index("people", :column => ["last_name", "first_name"]) }
assert_nothing_raised { Person.connection.add_index("people", ["last_name", "first_name"]) }
assert_nothing_raised { Person.connection.remove_index("people", :name => "index_people_on_last_name_and_first_name") }
assert_nothing_raised { Person.connection.add_index("people", ["last_name", "first_name"]) }
assert_nothing_raised { Person.connection.remove_index("people", "last_name_and_first_name") }
# Oracle adapter cannot have specified index name larger than 30 characters
# Oracle adapter is shortening index name when just column list is given
unless current_adapter?(:OracleAdapter)
assert_nothing_raised { Person.connection.add_index("people", ["last_name", "first_name"]) }
assert_nothing_raised { Person.connection.remove_index("people", :name => "index_people_on_last_name_and_first_name") }
assert_nothing_raised { Person.connection.add_index("people", ["last_name", "first_name"]) }
assert_nothing_raised { Person.connection.remove_index("people", "last_name_and_first_name") }
end
assert_nothing_raised { Person.connection.add_index("people", ["last_name", "first_name"]) }
assert_nothing_raised { Person.connection.remove_index("people", ["last_name", "first_name"]) }
assert_nothing_raised { Person.connection.add_index("people", ["last_name"], :length => 10) }
Expand Down Expand Up @@ -737,13 +741,7 @@ def test_remove_column_with_multi_column_index
table.column :hat_size, :integer
table.column :hat_style, :string, :limit => 100
end
# Oracle index names should be 30 or less characters
if current_adapter?(:OracleAdapter)
ActiveRecord::Base.connection.add_index "hats", ["hat_style", "hat_size"], :unique => true,
:name => 'index_hats_on_hat_style_size'
else
ActiveRecord::Base.connection.add_index "hats", ["hat_style", "hat_size"], :unique => true
end
ActiveRecord::Base.connection.add_index "hats", ["hat_style", "hat_size"], :unique => true

assert_nothing_raised { Person.connection.remove_column("hats", "hat_size") }
ensure
Expand Down

0 comments on commit f12f377

Please sign in to comment.