diff options
author | Sean Griffin <sean@seantheprogrammer.com> | 2016-12-05 13:51:51 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-05 13:51:51 -0500 |
commit | 1f143686f3cfdf52c3816b9925c683bb77451f23 (patch) | |
tree | a3a0f5112a75ad68f2498d3ee9b11595f95389ec /activerecord | |
parent | 057c8f257d57f99a6bb80c59429cac2aab3422da (diff) | |
parent | 7f0567b43b73b1bd1a16bfac9cd32fcbf1321b51 (diff) | |
download | rails-1f143686f3cfdf52c3816b9925c683bb77451f23.tar.gz rails-1f143686f3cfdf52c3816b9925c683bb77451f23.tar.bz2 rails-1f143686f3cfdf52c3816b9925c683bb77451f23.zip |
Merge pull request #27264 from kamipo/fix_change_column_lose_comment
Fix that `change_column` lose a comment
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb | 4 | ||||
-rw-r--r-- | activerecord/test/cases/comment_test.rb | 3 |
2 files changed, 5 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb index 98152853c2..db0ff749c1 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb @@ -769,6 +769,10 @@ module ActiveRecord options[:null] = column.null end + unless options.key?(:comment) + options[:comment] = column.comment + end + td = create_table_definition(table_name) cd = td.new_column_definition(column.name, type, options) schema_creation.accept(ChangeColumnDefinition.new(cd, column.name)) diff --git a/activerecord/test/cases/comment_test.rb b/activerecord/test/cases/comment_test.rb index 262ad319be..a625299e8d 100644 --- a/activerecord/test/cases/comment_test.rb +++ b/activerecord/test/cases/comment_test.rb @@ -2,7 +2,6 @@ require "cases/helper" require "support/schema_dumping_helper" if ActiveRecord::Base.connection.supports_comments? - class CommentTest < ActiveRecord::TestCase include SchemaDumpingHelper @@ -102,6 +101,7 @@ if ActiveRecord::Base.connection.supports_comments? # Do all the stuff from other tests @connection.add_column :commenteds, :rating, :integer, comment: "I am running out of imagination" @connection.change_column :commenteds, :content, :string, comment: "Whoa, content describes itself!" + @connection.change_column :commenteds, :content, :string @connection.change_column :commenteds, :obvious, :string, comment: nil @connection.add_index :commenteds, :obvious, name: "idx_obvious", comment: "We need to see obvious comments" @@ -135,5 +135,4 @@ if ActiveRecord::Base.connection.supports_comments? assert_no_match %r[t\.string\s+"absent_comment", comment:\n], output end end - end |