mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Deprecate passing name
to indexes
like tables
Passing `name` to `tables` is already deprecated at #21601. Passing `name` to `indexes` is also unused.
This commit is contained in:
parent
032fe34803
commit
457e6c77d4
7 changed files with 29 additions and 5 deletions
|
@ -1,5 +1,9 @@
|
||||||
|
* Deprecate passing `name` to `indexes`.
|
||||||
|
|
||||||
|
*Ryuta Kamizono*
|
||||||
|
|
||||||
* Compare deserialized values for `PostgreSQL::OID::Hstore` types when
|
* Compare deserialized values for `PostgreSQL::OID::Hstore` types when
|
||||||
calling `ActiveRecord::Dirty#changed_in_place?`
|
calling `ActiveRecord::Dirty#changed_in_place?`.
|
||||||
|
|
||||||
Fixes #27502.
|
Fixes #27502.
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,9 @@ module ActiveRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns an array of indexes for the given table.
|
# Returns an array of indexes for the given table.
|
||||||
# def indexes(table_name, name = nil) end
|
def indexes(table_name, name = nil)
|
||||||
|
raise NotImplementedError, "#indexes is not implemented"
|
||||||
|
end
|
||||||
|
|
||||||
# Checks to see if an index exists on a table for a given index definition.
|
# Checks to see if an index exists on a table for a given index definition.
|
||||||
#
|
#
|
||||||
|
|
|
@ -367,6 +367,12 @@ module ActiveRecord
|
||||||
|
|
||||||
# Returns an array of indexes for the given table.
|
# Returns an array of indexes for the given table.
|
||||||
def indexes(table_name, name = nil) #:nodoc:
|
def indexes(table_name, name = nil) #:nodoc:
|
||||||
|
if name
|
||||||
|
ActiveSupport::Deprecation.warn(<<-MSG.squish)
|
||||||
|
Passing name to #indexes is deprecated without replacement.
|
||||||
|
MSG
|
||||||
|
end
|
||||||
|
|
||||||
indexes = []
|
indexes = []
|
||||||
current_index = nil
|
current_index = nil
|
||||||
execute_and_free("SHOW KEYS FROM #{quote_table_name(table_name)}", "SCHEMA") do |result|
|
execute_and_free("SHOW KEYS FROM #{quote_table_name(table_name)}", "SCHEMA") do |result|
|
||||||
|
|
|
@ -166,7 +166,13 @@ module ActiveRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns an array of indexes for the given table.
|
# Returns an array of indexes for the given table.
|
||||||
def indexes(table_name, name = nil)
|
def indexes(table_name, name = nil) # :nodoc:
|
||||||
|
if name
|
||||||
|
ActiveSupport::Deprecation.warn(<<-MSG.squish)
|
||||||
|
Passing name to #indexes is deprecated without replacement.
|
||||||
|
MSG
|
||||||
|
end
|
||||||
|
|
||||||
table = Utils.extract_schema_qualified_name(table_name.to_s)
|
table = Utils.extract_schema_qualified_name(table_name.to_s)
|
||||||
|
|
||||||
result = query(<<-SQL, "SCHEMA")
|
result = query(<<-SQL, "SCHEMA")
|
||||||
|
|
|
@ -316,6 +316,12 @@ module ActiveRecord
|
||||||
|
|
||||||
# Returns an array of indexes for the given table.
|
# Returns an array of indexes for the given table.
|
||||||
def indexes(table_name, name = nil) #:nodoc:
|
def indexes(table_name, name = nil) #:nodoc:
|
||||||
|
if name
|
||||||
|
ActiveSupport::Deprecation.warn(<<-MSG.squish)
|
||||||
|
Passing name to #indexes is deprecated without replacement.
|
||||||
|
MSG
|
||||||
|
end
|
||||||
|
|
||||||
exec_query("PRAGMA index_list(#{quote_table_name(table_name)})", "SCHEMA").map do |row|
|
exec_query("PRAGMA index_list(#{quote_table_name(table_name)})", "SCHEMA").map do |row|
|
||||||
sql = <<-SQL
|
sql = <<-SQL
|
||||||
SELECT sql
|
SELECT sql
|
||||||
|
|
|
@ -95,7 +95,7 @@ module ActiveRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_indexes_logs_name
|
def test_indexes_logs_name
|
||||||
@connection.indexes("items", "hello")
|
assert_deprecated { @connection.indexes("items", "hello") }
|
||||||
assert_equal "SCHEMA", @subscriber.logged[0][1]
|
assert_equal "SCHEMA", @subscriber.logged[0][1]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -287,7 +287,7 @@ module ActiveRecord
|
||||||
def test_indexes_logs_name
|
def test_indexes_logs_name
|
||||||
with_example_table do
|
with_example_table do
|
||||||
assert_logged [["PRAGMA index_list(\"ex\")", "SCHEMA", []]] do
|
assert_logged [["PRAGMA index_list(\"ex\")", "SCHEMA", []]] do
|
||||||
@conn.indexes("ex", "hello")
|
assert_deprecated { @conn.indexes("ex", "hello") }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue