From 72bf3ded097f1c492f00bd07c9148ef0bf1d3973 Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Sat, 8 Oct 2016 09:04:50 +0900 Subject: Prevent to create blank comment Currently blank comment does not dump to `db/schema.rb`. But created it even if specified blank. --- activerecord/lib/active_record/schema_dumper.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'activerecord/lib/active_record/schema_dumper.rb') diff --git a/activerecord/lib/active_record/schema_dumper.rb b/activerecord/lib/active_record/schema_dumper.rb index ab2d64e903..41fed004a0 100644 --- a/activerecord/lib/active_record/schema_dumper.rb +++ b/activerecord/lib/active_record/schema_dumper.rb @@ -128,9 +128,7 @@ HEADER table_options = @connection.table_options(table) if table_options.present? - table_options.each do |key, value| - tbl.print ", #{key}: #{value.inspect}" if value.present? - end + tbl.print ", #{format_options(table_options)}" end tbl.puts " do |t|" @@ -237,6 +235,10 @@ HEADER end end + def format_options(options) + options.map { |key, value| "#{key}: #{value.inspect}" if value }.compact.join(", ") + end + def remove_prefix_and_suffix(table) table.gsub(/^(#{@options[:table_name_prefix]})(.+)(#{@options[:table_name_suffix]})$/, "\\2") end -- cgit v1.2.3