Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not log internal options when running migrations #47648

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 17 additions & 3 deletions activerecord/lib/active_record/migration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -969,9 +969,7 @@ def connection
end

def method_missing(method, *arguments, &block)
arg_list = arguments.map(&:inspect) * ", "

say_with_time "#{method}(#{arg_list})" do
say_with_time "#{method}(#{format_arguments(arguments)})" do
unless connection.respond_to? :revert
unless arguments.empty? || [:execute, :enable_extension, :disable_extension].include?(method)
arguments[0] = proper_table_name(arguments.first, table_name_options)
Expand Down Expand Up @@ -1080,6 +1078,22 @@ def execute_block
end
end

def format_arguments(arguments)
arg_list = arguments[0...-1].map(&:inspect)
last_arg = arguments.last
if last_arg.is_a?(Hash)
last_arg = last_arg.reject { |k, _v| internal_option?(k) }
arg_list << last_arg.inspect unless last_arg.empty?
else
arg_list << last_arg.inspect
end
arg_list.join(", ")
end

def internal_option?(option_name)
option_name.start_with?("_")
end

def command_recorder
CommandRecorder.new(connection)
end
Expand Down