diff options
author | Jeremy Daer <jeremydaer@gmail.com> | 2016-04-17 13:35:16 -0700 |
---|---|---|
committer | Jeremy Daer <jeremydaer@gmail.com> | 2016-04-18 12:42:24 -0700 |
commit | 485e7f25f29ca1ca23bb214b802cf68840dabbb6 (patch) | |
tree | 535f0c96556f268df114350891bbdce75bbe054a /activerecord/lib/active_record/connection_adapters/mysql/schema_creation.rb | |
parent | b39131e8bdb65a9ee51e49d7fe8f058e702e173b (diff) | |
download | rails-485e7f25f29ca1ca23bb214b802cf68840dabbb6.tar.gz rails-485e7f25f29ca1ca23bb214b802cf68840dabbb6.tar.bz2 rails-485e7f25f29ca1ca23bb214b802cf68840dabbb6.zip |
Database comments: switch to keyword args for new table options
* Switch to keyword args where we can without breaking compat.
* Use add_table_options! for :options, too.
* Some code polish.
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/mysql/schema_creation.rb')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/mysql/schema_creation.rb | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/mysql/schema_creation.rb b/activerecord/lib/active_record/connection_adapters/mysql/schema_creation.rb index 5ab81640e8..0384079da2 100644 --- a/activerecord/lib/active_record/connection_adapters/mysql/schema_creation.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql/schema_creation.rb @@ -25,10 +25,11 @@ module ActiveRecord add_column_position!(change_column_sql, column_options(o.column)) end - def add_table_options!(sql, options) + def add_table_options!(create_sql, options) super - if options[:comment] - sql << "COMMENT #{quote(options[:comment])} " + + if comment = options[:comment] + create_sql << " COMMENT #{quote(comment)}" end end @@ -39,17 +40,21 @@ module ActiveRecord end def add_column_options!(sql, options) - if options[:charset] - sql << " CHARACTER SET #{options[:charset]}" + if charset = options[:charset] + sql << " CHARACTER SET #{charset}" end - if options[:collation] - sql << " COLLATE #{options[:collation]}" + + if collation = options[:collation] + sql << " COLLATE #{collation}" end - new_sql = super - if options[:comment] - new_sql << " COMMENT #{quote(options[:comment])}" + + super + + if comment = options[:comment] + sql << " COMMENT #{quote(comment)}" end - new_sql + + sql end def add_column_position!(sql, options) @@ -58,6 +63,7 @@ module ActiveRecord elsif options[:after] sql << " AFTER #{quote_column_name(options[:after])}" end + sql end |