Incorrect collation returned for VARCHAR columns #162
Replies: 2 comments
-
Hi @abonander ! Thank you for letting us know about this! We are always striving to improve PlanetScale's support for various language drivers/connectors and frameworks. We appreciate you creating this issue, so please keep that in mind as I attempt to walk through the details for everyone. 🙂 The collation defined for the table and/or columns is not ignored, as shown in the linked ticket (unless I missed something?):
But if SQLx gets around supporting all MySQL compatible collations by attempting to set the FWIW MySQL 8.0 (which PlanetScale uses) has been GA for 4 years now and 5.7 is slated for EOL next year, and more importantly that old
It's important to note that collations are used for comparisons and sorting (character set determines the bytes stored whereas the collation determines what logical value is equal to or greater/less than another following linguistic rules rather than using byte comparisons), so they are crucial, and that old collation is not a good default — at least the older but not-so-old
BUT, setting all of that aside this is a valid report (don't want to imply otherwise) and this is actually due to underlying Vitess behavior. We're looking into that on the Vitess OSS project side and kicked off a discussion on that. If the Thank you for the issue! Even if SQLx did support the newer MySQL collations this is likely to cause issues with other frameworks and we need to think about how best to address this. |
Beta Was this translation helpful? Give feedback.
-
PlanetScale follows Vitess' behavior for connection collations, which is documented in the official Vitess docs. Quoting from the docs:
This may appear inconvenient, but here's a few points I'd like to highlight:
Let me know if you have any other questions about collations. Cheers! |
Beta Was this translation helpful? Give feedback.
-
In SQLx (database client for Rust) we got the following bug report related to Planetscale: launchbadge/sqlx#1690
If you follow the discussion, it appears that collations are getting mixed up for
VARCHAR
columns. The user's schema declaresutf8mb4_bin
as the collation and SQLx sets the default collation on the connection to beutf8mb4_unicode_ci
, but the returnedColumnDefinition
s for a query against the table report the collation asutf8m4_0900_ai_ci
.SQLx's support for collations isn't great and the logic we use to differentiate character strings from binary strings could be better, but it also seems like Planetscale is ignoring both the requested collation on the connection as well as the nominal collation on the source column.
Beta Was this translation helpful? Give feedback.
All reactions