Skip to content

Commit ee7db77

Browse files
committed
Don't use send when we own the method
1 parent e1a41fb commit ee7db77

File tree

2 files changed

+35
-35
lines changed

2 files changed

+35
-35
lines changed

activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,40 @@ def update_table_definition(table_name, base) #:nodoc:
739739
Table.new(table_name, base)
740740
end
741741

742+
def add_index_options(table_name, column_name, options = {}) #:nodoc:
743+
column_names = Array(column_name)
744+
index_name = index_name(table_name, column: column_names)
745+
746+
options.assert_valid_keys(:unique, :order, :name, :where, :length, :internal, :using, :algorithm, :type)
747+
748+
index_type = options[:unique] ? "UNIQUE" : ""
749+
index_type = options[:type].to_s if options.key?(:type)
750+
index_name = options[:name].to_s if options.key?(:name)
751+
max_index_length = options.fetch(:internal, false) ? index_name_length : allowed_index_name_length
752+
753+
if options.key?(:algorithm)
754+
algorithm = index_algorithms.fetch(options[:algorithm]) {
755+
raise ArgumentError.new("Algorithm must be one of the following: #{index_algorithms.keys.map(&:inspect).join(', ')}")
756+
}
757+
end
758+
759+
using = "USING #{options[:using]}" if options[:using].present?
760+
761+
if supports_partial_index?
762+
index_options = options[:where] ? " WHERE #{options[:where]}" : ""
763+
end
764+
765+
if index_name.length > max_index_length
766+
raise ArgumentError, "Index name '#{index_name}' on table '#{table_name}' is too long; the limit is #{max_index_length} characters"
767+
end
768+
if table_exists?(table_name) && index_name_exists?(table_name, index_name, false)
769+
raise ArgumentError, "Index name '#{index_name}' on table '#{table_name}' already exists"
770+
end
771+
index_columns = quoted_columns_for_index(column_names, options).join(", ")
772+
773+
[index_name, index_type, index_columns, index_options, algorithm, using]
774+
end
775+
742776
protected
743777
def add_index_sort_order(option_strings, column_names, options = {})
744778
if options.is_a?(Hash) && order = options[:order]
@@ -769,40 +803,6 @@ def options_include_default?(options)
769803
options.include?(:default) && !(options[:null] == false && options[:default].nil?)
770804
end
771805

772-
def add_index_options(table_name, column_name, options = {})
773-
column_names = Array(column_name)
774-
index_name = index_name(table_name, column: column_names)
775-
776-
options.assert_valid_keys(:unique, :order, :name, :where, :length, :internal, :using, :algorithm, :type)
777-
778-
index_type = options[:unique] ? "UNIQUE" : ""
779-
index_type = options[:type].to_s if options.key?(:type)
780-
index_name = options[:name].to_s if options.key?(:name)
781-
max_index_length = options.fetch(:internal, false) ? index_name_length : allowed_index_name_length
782-
783-
if options.key?(:algorithm)
784-
algorithm = index_algorithms.fetch(options[:algorithm]) {
785-
raise ArgumentError.new("Algorithm must be one of the following: #{index_algorithms.keys.map(&:inspect).join(', ')}")
786-
}
787-
end
788-
789-
using = "USING #{options[:using]}" if options[:using].present?
790-
791-
if supports_partial_index?
792-
index_options = options[:where] ? " WHERE #{options[:where]}" : ""
793-
end
794-
795-
if index_name.length > max_index_length
796-
raise ArgumentError, "Index name '#{index_name}' on table '#{table_name}' is too long; the limit is #{max_index_length} characters"
797-
end
798-
if table_exists?(table_name) && index_name_exists?(table_name, index_name, false)
799-
raise ArgumentError, "Index name '#{index_name}' on table '#{table_name}' already exists"
800-
end
801-
index_columns = quoted_columns_for_index(column_names, options).join(", ")
802-
803-
[index_name, index_type, index_columns, index_options, algorithm, using]
804-
end
805-
806806
def index_name_for_remove(table_name, options = {})
807807
index_name = index_name(table_name, options)
808808

activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def add_column_position!(sql, options)
4444
end
4545

4646
def index_in_create(table_name, column_name, options)
47-
index_name, index_type, index_columns, index_options, index_algorithm, index_using = @conn.send(:add_index_options, table_name, column_name, options)
47+
index_name, index_type, index_columns, index_options, index_algorithm, index_using = @conn.add_index_options(table_name, column_name, options)
4848
"#{index_type} INDEX #{quote_column_name(index_name)} #{index_using} (#{index_columns})#{index_options} #{index_algorithm}".gsub(' ', ' ').strip
4949
end
5050
end

0 commit comments

Comments
 (0)