From 5f2bc3a6a00a2277481de7241f7a2066e886b84d Mon Sep 17 00:00:00 2001 From: Guilherme Goettems Schneider Date: Fri, 31 May 2019 16:59:47 -0300 Subject: Fix table comment also being applied to the primary key column --- activerecord/CHANGELOG.md | 4 ++++ .../active_record/connection_adapters/abstract/schema_statements.rb | 2 +- activerecord/test/cases/comment_test.rb | 5 +++++ 3 files changed, 10 insertions(+), 1 deletion(-) (limited to 'activerecord') diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index 8c5342edb2..2b5fc1c2f8 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,3 +1,7 @@ +* Fix table comment also being applied to the primary key column + + *Guilherme Goettems Schneider* + * Allow generated `create_table` migrations to include or skip timestamps. *Michael Duchemin* diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb index 107d1ce855..bec22c9b03 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb @@ -302,7 +302,7 @@ module ActiveRecord 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 diff --git a/activerecord/test/cases/comment_test.rb b/activerecord/test/cases/comment_test.rb index 584e03d196..f2f28462d1 100644 --- a/activerecord/test/cases/comment_test.rb +++ b/activerecord/test/cases/comment_test.rb @@ -44,6 +44,11 @@ if ActiveRecord::Base.connection.supports_comments? @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 -- cgit v1.2.3