You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While upgrading from v1.8.1 to v1.9.0 I noticed that it no longer seems to be possible to set a charset when you're constructing a mysql.Config object yourself rather than parsing a DSN.
In 1.8.1, you would set your charset with something like:
which would be translated to a SET NAMES call in connection.go. This logic seems to have been removed in v1.9.0, and specifying the character set in this way results in an error as it is now translated to SET charset = utf8mb4.
Instead in v1.9.0, there is a charsets option on mysql.Config, which is translated into SET NAMES in connector.go.
Unfortunately this field is private, so the only way of setting it appears to by using mysql.ParseDSN to construct your config, rather than mysql.NewConfig. I was just wondering if it was expected that this field was private. Is there some way of setting it (other than the slightly horrible mysql.ParseDSN(cfg.FormatDSN() + "&charset=utf8mb4"))?
Configuration
Driver version (or git SHA): v1.9.0
Go version: 1.24.0
Server version: MySQL 8.0.41
Server OS: Ubuntu 22.04
The text was updated successfully, but these errors were encountered:
Issue description
While upgrading from v1.8.1 to v1.9.0 I noticed that it no longer seems to be possible to set a charset when you're constructing a
mysql.Config
object yourself rather than parsing a DSN.In 1.8.1, you would set your charset with something like:
which would be translated to a
SET NAMES
call in connection.go. This logic seems to have been removed in v1.9.0, and specifying the character set in this way results in an error as it is now translated toSET charset = utf8mb4
.Instead in v1.9.0, there is a
charsets
option onmysql.Config
, which is translated intoSET NAMES
in connector.go.Unfortunately this field is private, so the only way of setting it appears to by using
mysql.ParseDSN
to construct your config, rather thanmysql.NewConfig
. I was just wondering if it was expected that this field was private. Is there some way of setting it (other than the slightly horriblemysql.ParseDSN(cfg.FormatDSN() + "&charset=utf8mb4")
)?Configuration
Driver version (or git SHA): v1.9.0
Go version: 1.24.0
Server version: MySQL 8.0.41
Server OS: Ubuntu 22.04
The text was updated successfully, but these errors were encountered: