Browse files

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>
  • Loading branch information...
1 parent af6ec60 commit ff22b9d451efc4251c28d11453f05fed95378af4 @pupeno pupeno committed with josevalim Jun 12, 2010
View
2 activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
@@ -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.
View
16 activerecord/test/cases/migration_test.rb
@@ -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

0 comments on commit ff22b9d

Please sign in to comment.