diff options
author | Kasper Timm Hansen <kaspth@gmail.com> | 2016-10-28 13:46:06 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-28 13:46:06 +0200 |
commit | 86bf5adaa810ef9d988cc64dbe1b466f0f74e817 (patch) | |
tree | dd529bfefb5be514dde084ca59c5f6d95e9d24b4 | |
parent | 3f2046f00ab0046f9252a5a7b52f617028bc4e0c (diff) | |
parent | 444cf0d6424dcfaef009b9046b23c281791f0e9b (diff) | |
download | rails-86bf5adaa810ef9d988cc64dbe1b466f0f74e817.tar.gz rails-86bf5adaa810ef9d988cc64dbe1b466f0f74e817.tar.bz2 rails-86bf5adaa810ef9d988cc64dbe1b466f0f74e817.zip |
Merge pull request #26688 from kamipo/remove_respond_to_indexes
Remove unnecessary `respond_to?(:indexes)` checking
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb | 4 | ||||
-rw-r--r-- | activerecord/test/cases/adapter_test.rb | 23 |
2 files changed, 9 insertions, 18 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 5d2943e398..151629b02a 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb @@ -1199,10 +1199,6 @@ module ActiveRecord def index_name_for_remove(table_name, options = {}) return options[:name] if can_remove_index_by_name?(options) - # if the adapter doesn't support the indexes call the best we can do - # is return the default index name for the options provided - return index_name(table_name, options) unless respond_to?(:indexes) - checks = [] if options.is_a?(Hash) diff --git a/activerecord/test/cases/adapter_test.rb b/activerecord/test/cases/adapter_test.rb index cfbc8ab942..8bcecf2ed3 100644 --- a/activerecord/test/cases/adapter_test.rb +++ b/activerecord/test/cases/adapter_test.rb @@ -72,20 +72,15 @@ module ActiveRecord def test_indexes idx_name = "accounts_idx" - if @connection.respond_to?(:indexes) - indexes = @connection.indexes("accounts") - assert indexes.empty? - - @connection.add_index :accounts, :firm_id, name: idx_name - indexes = @connection.indexes("accounts") - assert_equal "accounts", indexes.first.table - assert_equal idx_name, indexes.first.name - assert !indexes.first.unique - assert_equal ["firm_id"], indexes.first.columns - else - warn "#{@connection.class} does not respond to #indexes" - end - + indexes = @connection.indexes("accounts") + assert indexes.empty? + + @connection.add_index :accounts, :firm_id, name: idx_name + indexes = @connection.indexes("accounts") + assert_equal "accounts", indexes.first.table + assert_equal idx_name, indexes.first.name + assert !indexes.first.unique + assert_equal ["firm_id"], indexes.first.columns ensure @connection.remove_index(:accounts, name: idx_name) rescue nil end |