Fix remove_index issue when provided :name is a symbol

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
This commit is contained in:
Tim Connor
2010-09-27 11:56:18 +13:00
committed by Santiago Pastorino
parent 56de4e9a80
commit d6f7b7d353
2 changed files with 2 additions and 2 deletions

View File

@@ -404,7 +404,7 @@ module ActiveRecord
# as there's no way to determine the correct answer in that case.
def index_name_exists?(table_name, index_name, default)
return default unless respond_to?(:indexes)
indexes(table_name).detect { |i| i.name == index_name }
indexes(table_name).detect { |i| i.name == index_name.to_s }
end
# Returns a string of <tt>CREATE TABLE</tt> SQL statement(s) for recreating the

View File

@@ -91,7 +91,7 @@ if ActiveRecord::Base.connection.supports_migrations?
# 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.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