Skip to content

Commit

Permalink
Merge pull request #36373 from guigs/fix-table-comment-also-being-app…
Browse files Browse the repository at this point in the history
…lied-to-the-primary-key-column

Fix table comment also being applied to the primary key column
  • Loading branch information
kamipo committed Jun 2, 2019
1 parent f355f92 commit 4361f09
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions activerecord/CHANGELOG.md
@@ -1,3 +1,7 @@
* Fix table comment also being applied to the primary key column.

*Guilherme Goettems Schneider*

* Fix merging left_joins to maintain its own `join_type` context.

Fixes #36103.
Expand Down
Expand Up @@ -302,7 +302,7 @@ def create_table(table_name, **options)
if pk.is_a?(Array)
td.primary_keys pk
else
td.primary_key pk, options.fetch(:id, :primary_key), options
td.primary_key pk, options.fetch(:id, :primary_key), options.except(:comment)
end
end

Expand Down
5 changes: 5 additions & 0 deletions activerecord/test/cases/comment_test.rb
Expand Up @@ -44,6 +44,11 @@ class BlankComment < ActiveRecord::Base
@connection.drop_table "blank_comments", if_exists: true
end

def test_primary_key_comment
column = Commented.columns_hash["id"]
assert_nil column.comment
end

def test_column_created_in_block
column = Commented.columns_hash["name"]
assert_equal :string, column.type
Expand Down

0 comments on commit 4361f09

Please sign in to comment.