From 5b14129d8d4ad302b4e11df6bd5c7891b75f393c Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Fri, 23 Dec 2016 15:51:11 +0900 Subject: Privatize unneededly protected methods in Active Record --- .../connection_adapters/abstract_mysql_adapter.rb | 36 ++++++++++------------ 1 file changed, 17 insertions(+), 19 deletions(-) (limited to 'activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb') diff --git a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb index 6985d2c1b2..68a88e71ba 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb @@ -649,9 +649,9 @@ module ActiveRecord !native_database_types[type].nil? end - protected + private - def initialize_type_map(m) # :nodoc: + def initialize_type_map(m) super register_class_with_limit m, %r(char)i, MysqlString @@ -691,7 +691,7 @@ module ActiveRecord end end - def register_integer_type(mapping, key, options) # :nodoc: + def register_integer_type(mapping, key, options) mapping.register_type(key) do |sql_type| if /\bunsigned\b/.match?(sql_type) Type::UnsignedInteger.new(options) @@ -701,7 +701,7 @@ module ActiveRecord end end - def extract_precision(sql_type) + def extract_precision(sql_type) # :doc: if /time/.match?(sql_type) super || 0 else @@ -709,11 +709,11 @@ module ActiveRecord end end - def fetch_type_metadata(sql_type, extra = "") + def fetch_type_metadata(sql_type, extra = "") # :doc: MySQL::TypeMetadata.new(super(sql_type), extra: extra) end - def add_index_length(quoted_columns, **options) + def add_index_length(quoted_columns, **options) # :doc: if length = options[:length] case length when Hash @@ -727,7 +727,7 @@ module ActiveRecord quoted_columns end - def add_options_for_index_columns(quoted_columns, **options) + def add_options_for_index_columns(quoted_columns, **options) # :doc: quoted_columns = add_index_length(quoted_columns, options) super end @@ -743,7 +743,7 @@ module ActiveRecord ER_CANNOT_ADD_FOREIGN = 1215 ER_CANNOT_CREATE_TABLE = 1005 - def translate_exception(exception, message) + def translate_exception(exception, message) # :doc: case error_number(exception) when ER_DUP_ENTRY RecordNotUnique.new(message) @@ -770,13 +770,13 @@ module ActiveRecord end end - def add_column_sql(table_name, column_name, type, options = {}) + def add_column_sql(table_name, column_name, type, options = {}) # :doc: td = create_table_definition(table_name) cd = td.new_column_definition(column_name, type, options) schema_creation.accept(AddColumnDefinition.new(cd)) end - def change_column_sql(table_name, column_name, type, options = {}) + def change_column_sql(table_name, column_name, type, options = {}) # :doc: column = column_for(table_name, column_name) unless options_include_default?(options) @@ -796,7 +796,7 @@ module ActiveRecord schema_creation.accept(ChangeColumnDefinition.new(cd, column.name)) end - def rename_column_sql(table_name, column_name, new_column_name) + def rename_column_sql(table_name, column_name, new_column_name) # :doc: column = column_for(table_name, column_name) options = { default: column.default, @@ -810,35 +810,33 @@ module ActiveRecord schema_creation.accept(ChangeColumnDefinition.new(cd, column.name)) end - def remove_column_sql(table_name, column_name, type = nil, options = {}) + def remove_column_sql(table_name, column_name, type = nil, options = {}) # :doc: "DROP #{quote_column_name(column_name)}" end - def remove_columns_sql(table_name, *column_names) + def remove_columns_sql(table_name, *column_names) # :doc: column_names.map { |column_name| remove_column_sql(table_name, column_name) } end - def add_index_sql(table_name, column_name, options = {}) + def add_index_sql(table_name, column_name, options = {}) # :doc: index_name, index_type, index_columns, _, index_algorithm, index_using = add_index_options(table_name, column_name, options) index_algorithm[0, 0] = ", " if index_algorithm.present? "ADD #{index_type} INDEX #{quote_column_name(index_name)} #{index_using} (#{index_columns})#{index_algorithm}" end - def remove_index_sql(table_name, options = {}) + def remove_index_sql(table_name, options = {}) # :doc: index_name = index_name_for_remove(table_name, options) "DROP INDEX #{index_name}" end - def add_timestamps_sql(table_name, options = {}) + def add_timestamps_sql(table_name, options = {}) # :doc: [add_column_sql(table_name, :created_at, :datetime, options), add_column_sql(table_name, :updated_at, :datetime, options)] end - def remove_timestamps_sql(table_name, options = {}) + def remove_timestamps_sql(table_name, options = {}) # :doc: [remove_column_sql(table_name, :updated_at), remove_column_sql(table_name, :created_at)] end - private - # MySQL is too stupid to create a temporary table for use subquery, so we have # to give it some prompting in the form of a subsubquery. Ugh! def subquery_for(key, select) -- cgit v1.2.3