Skip to content

Commit

Permalink
Remove deprecated argument name from #indexes
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelfranca committed Oct 23, 2017
1 parent 7df6e3f commit d6b779e
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 33 deletions.
4 changes: 4 additions & 0 deletions activerecord/CHANGELOG.md
@@ -1,3 +1,7 @@
* Remove deprecated argument `name` from `#indexes`.

*Rafael Mendonça França*

* Remove deprecated method `ActiveRecord::Migrator.schema_migrations_table_name`.

*Rafael Mendonça França*
Expand Down
Expand Up @@ -79,7 +79,7 @@ def view_exists?(view_name)
end

# Returns an array of indexes for the given table.
def indexes(table_name, name = nil)
def indexes(table_name)
raise NotImplementedError, "#indexes is not implemented"
end

Expand Down
Expand Up @@ -5,13 +5,7 @@ module ConnectionAdapters
module MySQL
module SchemaStatements # :nodoc:
# Returns an array of indexes for the given table.
def indexes(table_name, name = nil)
if name
ActiveSupport::Deprecation.warn(<<-MSG.squish)
Passing name to #indexes is deprecated without replacement.
MSG
end

def indexes(table_name)
indexes = []
current_index = nil
execute_and_free("SHOW KEYS FROM #{quote_table_name(table_name)}", "SCHEMA") do |result|
Expand Down
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require "active_support/core_ext/string/strip"

module ActiveRecord
module ConnectionAdapters
module PostgreSQL
Expand Down Expand Up @@ -84,13 +82,7 @@ def index_name_exists?(table_name, index_name)
end

# Returns an array of indexes for the given table.
def indexes(table_name, name = nil) # :nodoc:
if name
ActiveSupport::Deprecation.warn(<<-MSG.squish)
Passing name to #indexes is deprecated without replacement.
MSG
end

def indexes(table_name) # :nodoc:
scope = quoted_scope(table_name)

result = query(<<-SQL, "SCHEMA")
Expand Down
Expand Up @@ -5,13 +5,7 @@ module ConnectionAdapters
module SQLite3
module SchemaStatements # :nodoc:
# Returns an array of indexes for the given table.
def indexes(table_name, name = nil)
if name
ActiveSupport::Deprecation.warn(<<-MSG.squish)
Passing name to #indexes is deprecated without replacement.
MSG
end

def indexes(table_name)
exec_query("PRAGMA index_list(#{quote_table_name(table_name)})", "SCHEMA").map do |row|
index_sql = query_value(<<-SQL, "SCHEMA")
SELECT sql
Expand Down
Expand Up @@ -103,7 +103,7 @@ def test_tables_logs_name
end

def test_indexes_logs_name
assert_deprecated { @connection.indexes("items", "hello") }
@connection.indexes("items")
assert_equal "SCHEMA", @subscriber.logged[0][1]
end

Expand Down
Expand Up @@ -269,14 +269,6 @@ def test_tables_logs_name
end
end

def test_indexes_logs_name
with_example_table do
assert_logged [["PRAGMA index_list(\"ex\")", "SCHEMA", []]] do
assert_deprecated { @conn.indexes("ex", "hello") }
end
end
end

def test_table_exists_logs_name
with_example_table do
sql = <<-SQL
Expand Down

0 comments on commit d6b779e

Please sign in to comment.