diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2016-06-10 07:57:22 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2016-06-10 07:57:22 +0900 |
commit | a31e837431ee131fbc6900f1b3c3d6ef09753f7a (patch) | |
tree | 6ba1db0e9e255627c541053afdf1f50c2a9e9862 /activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb | |
parent | f9a39e0d51400c62348e6e299d4c53e9eababef2 (diff) | |
download | rails-a31e837431ee131fbc6900f1b3c3d6ef09753f7a.tar.gz rails-a31e837431ee131fbc6900f1b3c3d6ef09753f7a.tar.bz2 rails-a31e837431ee131fbc6900f1b3c3d6ef09753f7a.zip |
Prevent `table_comment` query if a table doesn't have a comment
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb | 12 |
1 files changed, 9 insertions, 3 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 718a6c5b91..41c6b2d9bd 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb @@ -542,7 +542,9 @@ module ActiveRecord end end - def table_options(table_name) + def table_options(table_name) # :nodoc: + table_options = {} + create_table_info = create_table_info(table_name) # strip create_definitions and partition_options @@ -551,10 +553,14 @@ module ActiveRecord # strip AUTO_INCREMENT raw_table_options.sub!(/(ENGINE=\w+)(?: AUTO_INCREMENT=\d+)/, '\1') + table_options[:options] = raw_table_options + # strip COMMENT - raw_table_options.sub!(/ COMMENT='.+'/, '') + if raw_table_options.sub!(/ COMMENT='.+'/, '') + table_options[:comment] = table_comment(table_name) + end - raw_table_options + table_options end # Maps logical Rails types to MySQL-specific data types. |