Permalink
Browse files

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
  • Loading branch information...
rafaelfranca committed Apr 20, 2017
2 parents d87d0e3 + a8ee3e8 commit 5816c2028863096b5c41cc463256933b4437f5a9
@@ -64,14 +64,6 @@ def initialize(connection, logger, connection_options, config)
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
@@ -45,7 +45,17 @@ def indexes(table_name, name = nil)
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
@@ -18,7 +18,7 @@ def test_initializes_schema_migrations_for_encoding_utf8mb4
ActiveRecord::SchemaMigration.create_table
assert connection.column_exists?(table_name, :version, :string, collation: "utf8_general_ci")
assert connection.column_exists?(table_name, :version, :string)
end
end
@@ -29,7 +29,7 @@ def test_initializes_internal_metadata_for_encoding_utf8mb4
ActiveRecord::InternalMetadata.create_table
assert connection.column_exists?(table_name, :key, :string, collation: "utf8_general_ci")
assert connection.column_exists?(table_name, :key, :string)
end
end

0 comments on commit 5816c20

Please sign in to comment.