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
Hi, I'm one of the maintainers on WhoDB and I've ran into a use case where I'd like to see if a given collation is supported by this library. However I'm unable to directly check it since the array is private.
I've ran into a use case where I'd like to see if a given collation is supported by this library.
Please describe the use case. I don't want to expose the array.
In the UI we expose the Collation option to users, and I want do do a check in the backend to see if whatever option they put in is supported by the library and handle accordingly.
UIs that specify only collation are not recommended.
Also, the collations in the tables in this library are not necessarily the collations that are used.
It is better to let the user freely input charset and collation respectively.
this list is exported from one specific mysql version. newer/older mysql would have different collations.
This list is used when only collation name is specified. In this case, this driver send collation id in handshake packet. But the collation id may and may not used by the server. So this is not recommended.
Instead, we recommend using only charset or pair of charset and collation. In this case, this list is not used. Instead, this driver sends SET NAMES <charset> or SET NAMES <charset> COLLATE <collation> command to the server. The collation list might used in only handshake. This approach is recommended because:
Safe. Server returns OK/NG so we can know the charset/collation is actually used.
Newer collations can be used.
If you want to provide dropdown list for collations, please get collation list by SHOW COLLATIONS. Please don't use our list.
Activity
methane commentedon Jan 27, 2025
Please describe the use case.
I don't want to expose the array.
modelorona commentedon Jan 27, 2025
In the UI we expose the Collation option to users, and I want do do a check in the backend to see if whatever option they put in is supported by the library and handle accordingly.
methane commentedon Jan 27, 2025
UIs that specify only collation are not recommended.
Also, the collations in the tables in this library are not necessarily the collations that are used.
It is better to let the user freely input charset and collation respectively.
modelorona commentedon Jan 27, 2025
Would you mind elaborating on this?
methane commentedon Jan 27, 2025
this list is exported from one specific mysql version. newer/older mysql would have different collations.
This list is used when only collation name is specified. In this case, this driver send collation id in handshake packet. But the collation id may and may not used by the server. So this is not recommended.
Instead, we recommend using only charset or pair of charset and collation. In this case, this list is not used. Instead, this driver sends
SET NAMES <charset>orSET NAMES <charset> COLLATE <collation>command to the server. The collation list might used in only handshake. This approach is recommended because:If you want to provide dropdown list for collations, please get collation list by
SHOW COLLATIONS. Please don't use our list.methane commentedon Jan 27, 2025
See also: https://github.com/go-sql-driver/mysql?tab=readme-ov-file#unicode-support
modelorona commentedon Jan 27, 2025
I see, thank you for the explanation! Very helpful :)
packets: fix inverted unknown collation check (#1832)