diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2017-04-19 22:43:38 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-19 22:43:38 -0400 |
commit | 5816c2028863096b5c41cc463256933b4437f5a9 (patch) | |
tree | 3e79453488c58294c22fe1b42bec2443e623b854 /activerecord/lib/active_record/connection_adapters | |
parent | d87d0e34dae7511b234058d374507721843dc8ee (diff) | |
parent | a8ee3e8836fc5467d048a6334e94c198f086a737 (diff) | |
download | rails-5816c2028863096b5c41cc463256933b4437f5a9.tar.gz rails-5816c2028863096b5c41cc463256933b4437f5a9.tar.bz2 rails-5816c2028863096b5c41cc463256933b4437f5a9.zip |
Merge pull request #28733 from kamipo/dont_fallback_to_utf8mb3_after_mysql_8.0.0
Don't fallback to utf8mb3 after MySQL 8.0.0
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb | 8 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/mysql/schema_statements.rb | 10 |
2 files changed, 10 insertions, 8 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 71fa7b929c..c742799aab 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb @@ -64,14 +64,6 @@ module ActiveRecord end end - CHARSETS_OF_4BYTES_MAXLEN = ["utf8mb4", "utf16", "utf16le", "utf32"] - - def internal_string_options_for_primary_key # :nodoc: - super.tap { |options| - options[:collation] = collation.sub(/\A[^_]+/, "utf8") if CHARSETS_OF_4BYTES_MAXLEN.include?(charset) - } - end - def version #:nodoc: @version ||= Version.new(full_version.match(/^\d+\.\d+\.\d+/)[0]) end 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 571edffec7..f9e1e046ea 100644 --- a/activerecord/lib/active_record/connection_adapters/mysql/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql/schema_statements.rb @@ -45,7 +45,17 @@ module ActiveRecord indexes end + def internal_string_options_for_primary_key + super.tap do |options| + if CHARSETS_OF_4BYTES_MAXLEN.include?(charset) && (mariadb? || version < "8.0.0") + options[:collation] = collation.sub(/\A[^_]+/, "utf8") + end + end + end + private + CHARSETS_OF_4BYTES_MAXLEN = ["utf8mb4", "utf16", "utf16le", "utf32"] + def schema_creation MySQL::SchemaCreation.new(self) end |