aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2016-10-11 03:55:06 +0900
committerRyuta Kamizono <kamipo@gmail.com>2016-10-11 04:03:19 +0900
commit0780c444dbf9793fdffaa631fa929d77f109e24f (patch)
tree54de9e90fdf4d399fff3e3ff2206f38e29bc1d65 /activerecord/lib/active_record
parent15fa282148c3fef064e9cee6564f60ea32f6a2d5 (diff)
downloadrails-0780c444dbf9793fdffaa631fa929d77f109e24f.tar.gz
rails-0780c444dbf9793fdffaa631fa929d77f109e24f.tar.bz2
rails-0780c444dbf9793fdffaa631fa929d77f109e24f.zip
Fix table comment dumping
Follow up to #26735. If `table_options` returns `{ comment: nil }`, `create_table` line is broken. Example: ```ruby create_table "accounts", force: :cascade, do |t| ```
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb4
-rw-r--r--activerecord/lib/active_record/schema_dumper.rb2
2 files changed, 4 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
index 29a77580f5..83310233f0 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
@@ -239,7 +239,9 @@ module ActiveRecord
end
def table_options(table_name) # :nodoc:
- { comment: table_comment(table_name) }
+ if comment = table_comment(table_name)
+ { comment: comment }
+ end
end
# Returns a comment stored in database for given table
diff --git a/activerecord/lib/active_record/schema_dumper.rb b/activerecord/lib/active_record/schema_dumper.rb
index a1d7e3ef24..6f24e6d182 100644
--- a/activerecord/lib/active_record/schema_dumper.rb
+++ b/activerecord/lib/active_record/schema_dumper.rb
@@ -229,7 +229,7 @@ HEADER
end
def format_options(options)
- options.map { |key, value| "#{key}: #{value.inspect}" if value }.compact.join(", ")
+ options.map { |key, value| "#{key}: #{value.inspect}" }.join(", ")
end
def remove_prefix_and_suffix(table)