diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2017-02-13 15:38:40 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-13 15:38:40 -0300 |
commit | 2809f38ab8d75dabb5b053ac14f5e78a2ad802fa (patch) | |
tree | 65eaccbcdf3dd1c89efd01fce86a3625c8629e69 /activerecord | |
parent | b9bee5e895e218b17a5f4ad72c3cbf6204fa4145 (diff) | |
parent | 3cb27c50b9af388219e88b8e094b422234ad4caf (diff) | |
download | rails-2809f38ab8d75dabb5b053ac14f5e78a2ad802fa.tar.gz rails-2809f38ab8d75dabb5b053ac14f5e78a2ad802fa.tar.bz2 rails-2809f38ab8d75dabb5b053ac14f5e78a2ad802fa.zip |
Merge pull request #27986 from kamipo/add_default_index_type
Add `default_index_type?` to the generic schema dumper doesn't have the knowledge about an index type
Diffstat (limited to 'activerecord')
4 files changed, 13 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb index 808de5daca..6b14a498df 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb @@ -509,6 +509,10 @@ module ActiveRecord result end + def default_index_type?(index) # :nodoc: + index.using.nil? + end + private def initialize_type_map(m) 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 f743c80372..14269b4570 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb @@ -651,6 +651,10 @@ module ActiveRecord !native_database_types[type].nil? end + def default_index_type?(index) # :nodoc: + index.using == :btree || super + end + private def initialize_type_map(m) diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index 5ce61183cd..36c9815547 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -402,6 +402,10 @@ module ActiveRecord @connection.server_version end + def default_index_type?(index) # :nodoc: + index.using == :btree || super + end + private # See http://www.postgresql.org/docs/current/static/errcodes-appendix.html diff --git a/activerecord/lib/active_record/schema_dumper.rb b/activerecord/lib/active_record/schema_dumper.rb index cf4495326b..15533f0151 100644 --- a/activerecord/lib/active_record/schema_dumper.rb +++ b/activerecord/lib/active_record/schema_dumper.rb @@ -188,7 +188,7 @@ HEADER index_parts << "length: { #{format_options(index.lengths)} }" if index.lengths.present? index_parts << "order: { #{format_options(index.orders)} }" if index.orders.present? index_parts << "where: #{index.where.inspect}" if index.where - index_parts << "using: #{index.using.inspect}" if index.using && index.using != :btree + index_parts << "using: #{index.using.inspect}" if !@connection.default_index_type?(index) index_parts << "type: #{index.type.inspect}" if index.type index_parts << "comment: #{index.comment.inspect}" if index.comment index_parts |