From 606830d27a32fab23c0964b4383807fcdfdd7eba Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Sun, 16 Apr 2017 05:17:14 +0900 Subject: Support Descending Indexes for MySQL MySQL 8.0.1 and higher supports descending indexes: `DESC` in an index definition is no longer ignored. See https://dev.mysql.com/doc/refman/8.0/en/descending-indexes.html. --- .../lib/active_record/connection_adapters/abstract_mysql_adapter.rb | 4 +--- .../lib/active_record/connection_adapters/mysql/schema_statements.rb | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'activerecord/lib') 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 0866f58015..71fa7b929c 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb @@ -90,10 +90,8 @@ module ActiveRecord true end - # Technically MySQL allows to create indexes with the sort order syntax - # but at the moment (5.5) it doesn't yet implement them def supports_index_sort_order? - true + !mariadb? && version >= "8.0.1" end def supports_transaction_isolation? diff --git a/activerecord/lib/active_record/connection_adapters/mysql/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/mysql/schema_statements.rb index 1e58513387..571edffec7 100644 --- a/activerecord/lib/active_record/connection_adapters/mysql/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql/schema_statements.rb @@ -38,6 +38,7 @@ module ActiveRecord indexes.last.columns << row[:Column_name] indexes.last.lengths.merge!(row[:Column_name] => row[:Sub_part].to_i) if row[:Sub_part] + indexes.last.orders.merge!(row[:Column_name] => :desc) if row[:Collation] == "D" end end -- cgit v1.2.3