Fixed error when removing an index from a table name values, which is a reserved word, with test.

Signed-off-by: José Valim <jose.valim@gmail.com>
This commit is contained in:
J. Pablo Fernández 2010-06-12 03:25:18 +02:00 committed by José Valim
parent af6ec607fa
commit ff22b9d451
2 changed files with 17 additions and 1 deletions

@ -365,7 +365,7 @@ def remove_index(table_name, options = {})
end
def remove_index!(table_name, index_name) #:nodoc:
execute "DROP INDEX #{quote_column_name(index_name)} ON #{table_name}"
execute "DROP INDEX #{quote_column_name(index_name)} ON #{quote_table_name(table_name)}"
end
# Rename an index.

@ -1621,6 +1621,22 @@ def test_migrator_interleaved_migrations
end
end
class ReservedWordsMigrationTest < ActiveRecord::TestCase
def test_drop_index_from_table_named_values
connection = Person.connection
connection.create_table :values, :force => true do |t|
t.integer :value
end
connection.add_index :values, :value
# Just remove the index, it should not raise an exception
connection.remove_index :values, :column => :value
connection.drop_table :values rescue nil
end
end
class ChangeTableMigrationsTest < ActiveRecord::TestCase
def setup
@connection = Person.connection