diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2016-10-08 09:15:37 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2016-10-10 11:53:22 +0900 |
commit | 5025fd3a99c68f95bdd6fd43f382c62e9653236b (patch) | |
tree | 4dfbc554f4a66855b112aa971a904d2352a90c30 /activerecord/lib/active_record/connection_adapters | |
parent | 02989ee38f8cc5e82e7106ff8689d4635b016f40 (diff) | |
download | rails-5025fd3a99c68f95bdd6fd43f382c62e9653236b.tar.gz rails-5025fd3a99c68f95bdd6fd43f382c62e9653236b.tar.bz2 rails-5025fd3a99c68f95bdd6fd43f382c62e9653236b.zip |
Dump index options to pretty format
```ruby
# Before
t.index ["firm_id", "type", "rating"], name: "company_index", order: {"rating"=>:desc}, using: :btree
# After
t.index ["firm_id", "type", "rating"], name: "company_index", order: { rating: :desc }, using: :btree
```
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb | 4 |
2 files changed, 3 insertions, 3 deletions
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 51819f7980..0f1a83324b 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb @@ -1192,7 +1192,7 @@ module ActiveRecord def quoted_columns_for_index(column_names, **options) return [column_names] if column_names.is_a?(String) - quoted_columns = Hash[column_names.map { |name| [name, quote_column_name(name).dup] }] + quoted_columns = Hash[column_names.map { |name| [name.to_sym, quote_column_name(name).dup] }] add_options_for_index_columns(quoted_columns, options).values end 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 5923136df8..003ba6eff5 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb @@ -384,11 +384,11 @@ module ActiveRecord mysql_index_type = row[:Index_type].downcase.to_sym index_type = INDEX_TYPES.include?(mysql_index_type) ? mysql_index_type : nil index_using = INDEX_USINGS.include?(mysql_index_type) ? mysql_index_type : nil - indexes << IndexDefinition.new(row[:Table], row[:Key_name], row[:Non_unique].to_i == 0, [], [], nil, nil, index_type, index_using, row[:Index_comment].presence) + indexes << IndexDefinition.new(row[:Table], row[:Key_name], row[:Non_unique].to_i == 0, [], {}, nil, nil, index_type, index_using, row[:Index_comment].presence) end indexes.last.columns << row[:Column_name] - indexes.last.lengths << row[:Sub_part] + indexes.last.lengths.merge!(row[:Column_name] => row[:Sub_part]) if row[:Sub_part] end end |