Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set charset name utf8mb4 by default #1157

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ Mysql2::Client.new(
:database,
:socket = '/path/to/mysql.sock',
:flags = REMEMBER_OPTIONS | LONG_PASSWORD | LONG_FLAG | TRANSACTIONS | PROTOCOL_41 | SECURE_CONNECTION | MULTI_STATEMENTS,
:encoding = 'utf8',
:encoding = 'utf8mb4',
:read_timeout = seconds,
:write_timeout = seconds,
:connect_timeout = seconds,
Expand Down Expand Up @@ -309,7 +309,7 @@ Use the value `mysql2` as the adapter name. For example:
``` yaml
development:
adapter: mysql2
encoding: utf8
encoding: utf8mb4
database: my_db_name
username: root
password: my_password
Expand Down
4 changes: 2 additions & 2 deletions lib/mysql2/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def initialize(opts = {})
end
end

# force the encoding to utf8
self.charset_name = opts[:encoding] || 'utf8'
# force the encoding to utf8mb4
self.charset_name = opts[:encoding] || 'utf8mb4'

ssl_options = opts.values_at(:sslkey, :sslcert, :sslca, :sslcapath, :sslcipher)
ssl_set(*ssl_options) if ssl_options.any? || opts.key?(:sslverify)
Expand Down