From 63b2574cd461f48b34bdea30dcd312d02a2ad6b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J.=20Pablo=20Fern=C3=A1ndez?= Date: Sat, 12 Jun 2010 03:25:18 +0200 Subject: [PATCH 1/3] Fixed error when removing an index from a table name values, which is a reserved word, with test. --- .../abstract/schema_statements.rb | 2 +- activerecord/test/cases/migration_test.rb | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletions(-) diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb index d3499ce..57003b1 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb @@ -321,7 +321,7 @@ module ActiveRecord 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. diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb index ddadde8..7975847 100644 --- a/activerecord/test/cases/migration_test.rb +++ b/activerecord/test/cases/migration_test.rb @@ -1531,6 +1531,22 @@ if ActiveRecord::Base.connection.supports_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 -- 1.7.1 From d0f0f3f098d27471a0c85f5b98b36149cb0e7535 Mon Sep 17 00:00:00 2001 From: Paul Barry Date: Fri, 11 Jun 2010 23:03:47 -0400 Subject: [PATCH 2/3] Replaced statement in comment with an assertion --- activerecord/test/cases/migration_test.rb | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb index 7975847..85f71a5 100644 --- a/activerecord/test/cases/migration_test.rb +++ b/activerecord/test/cases/migration_test.rb @@ -1539,8 +1539,9 @@ if ActiveRecord::Base.connection.supports_migrations? end connection.add_index :values, :value - # Just remove the index, it should not raise an exception - connection.remove_index :values, :column => :value + assert_nothing_raised do + connection.remove_index :values, :column => :value + end connection.drop_table :values rescue nil end -- 1.7.1 From 67edb00350a8a1532a95e11c125d6d1b4c0d4e3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J.=20Pablo=20Fern=C3=A1ndez?= Date: Tue, 15 Jun 2010 11:03:30 +0200 Subject: [PATCH 3/3] Test that adding an index also doesn't raise an exception. --- activerecord/test/cases/migration_test.rb | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb index 85f71a5..3c4852c 100644 --- a/activerecord/test/cases/migration_test.rb +++ b/activerecord/test/cases/migration_test.rb @@ -1537,9 +1537,9 @@ if ActiveRecord::Base.connection.supports_migrations? connection.create_table :values, :force => true do |t| t.integer :value end - connection.add_index :values, :value assert_nothing_raised do + connection.add_index :values, :value connection.remove_index :values, :column => :value end -- 1.7.1