Skip to content

Commit 36f6ab2

Browse files
authored
Merge pull request rails#26753 from kamipo/fix_table_comment_dumping
Fix table comment dumping
2 parents 15fa282 + 0780c44 commit 36f6ab2

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,9 @@ def new_column(*args) # :nodoc:
239239
end
240240

241241
def table_options(table_name) # :nodoc:
242-
{ comment: table_comment(table_name) }
242+
if comment = table_comment(table_name)
243+
{ comment: comment }
244+
end
243245
end
244246

245247
# Returns a comment stored in database for given table

activerecord/lib/active_record/schema_dumper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ def foreign_keys(table, stream)
229229
end
230230

231231
def format_options(options)
232-
options.map { |key, value| "#{key}: #{value.inspect}" if value }.compact.join(", ")
232+
options.map { |key, value| "#{key}: #{value.inspect}" }.join(", ")
233233
end
234234

235235
def remove_prefix_and_suffix(table)

activerecord/test/cases/schema_dumper_test.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ def test_schema_dump
5151
output = standard_dump
5252
assert_match %r{create_table "accounts"}, output
5353
assert_match %r{create_table "authors"}, output
54+
assert_no_match %r{(?<=, ) do \|t\|}, output
5455
assert_no_match %r{create_table "schema_migrations"}, output
5556
assert_no_match %r{create_table "ar_internal_metadata"}, output
5657
end

0 commit comments

Comments
 (0)