From c41ef01aec40bfaa9af707551d1e8a1f9f7380d1 Mon Sep 17 00:00:00 2001 From: Seva Orlov Date: Mon, 11 Apr 2016 20:57:19 +0300 Subject: remove_index do not fetch indexes if name is specified There is no need to fetch all table indexes in remove_index if name is specified. If name is wrong, then StatementInvalid will be raised. Signed-off-by: Jeremy Daer --- activerecord/test/cases/adapter_test.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'activerecord/test/cases/adapter_test.rb') diff --git a/activerecord/test/cases/adapter_test.rb b/activerecord/test/cases/adapter_test.rb index 32391e2e8b..34e3bc9d66 100644 --- a/activerecord/test/cases/adapter_test.rb +++ b/activerecord/test/cases/adapter_test.rb @@ -87,6 +87,17 @@ module ActiveRecord @connection.remove_index(:accounts, :name => idx_name) rescue nil end + def test_remove_index_when_name_and_wrong_column_name_specified + index_name = "accounts_idx" + + @connection.add_index :accounts, :firm_id, :name => index_name + assert_raises ArgumentError do + @connection.remove_index :accounts, :name => index_name, :column => :wrong_column_name + end + ensure + @connection.remove_index(:accounts, :name => index_name) + end + def test_current_database if @connection.respond_to?(:current_database) assert_equal ARTest.connection_config['arunit']['database'], @connection.current_database -- cgit v1.2.3