-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Unexpected result of using in DSN string collation and charset parameters at the same time. #745
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
Comments
Please add the Go code that shows how you query the current charset and the current collation. |
|
Note that the documentation for
The workaround is to set only |
No problems while using charset and collation parameters separately. |
Go code: Output: |
charset is deprecated, and not recommended.
Why do you use both?
|
It's not my code: https://github.com/go-sql-driver/mysql/blob/master/connection.go#L62 Using both of them not deprecated: https://dev.mysql.com/doc/refman/5.7/en/charset-connection.html
|
@soslanco I meant about parameter of DSN. See here. https://github.com/go-sql-driver/mysql#charset
|
@methane Users can be wrong, despites a good intent (specifying both So the driver should catch this user error because it can: it should ignore |
I think there are two long-term solution:
|
I had issues with my collation_connection being utf8mb4_general_ci with That's quite a gotcha. |
I decided to fix this based on my experience of maintaining Python MySQL drivers.
|
Issue description
Result of using in DSN string charset and non default collation parameters together not as expected.
In file github.com/go-sql-driver/mysql/connection.go executed SET NAMES sql command without COLLATE parameter. Therefore connection collation = default collation for charset.
Example code
Result
Configuration
Driver version (or git SHA): bc14601
Go version: go1.9.3 linux/amd64
Server version: MariaDB 10.2.12
Server OS: RHEL7
The text was updated successfully, but these errors were encountered: