fix: [db] Change attributes.comment column charset to utf8mb4#10714
Open
brainstorm wants to merge 2 commits into
Open
fix: [db] Change attributes.comment column charset to utf8mb4#10714brainstorm wants to merge 2 commits into
brainstorm wants to merge 2 commits into
Conversation
c700827 to
2cf202b
Compare
Author
|
Hey! @iglocska First pull request here so let me know if I made some obvious mistake: for instance, I'm not too sure if you do database migrations through that |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix:
attributes.commentcolumn cannot store emoji charactersBug Description
The
attributes.commentcolumn usesutf8mb3_unicode_cicollation, which only supports 3-byte UTF-8 characters. When users try to add attribute comments containing emoji characters (especially flag emojis like 🇮 🇪 🇪 🇸 🇫 🇷 ), a PDO exception is thrown.Error:
Note: The SQLSTATE 22007 label "Invalid datetime format" is misleading. This is a character encoding issue, not datetime-related. MySQL reuses this SQLSTATE code for various conversion failures beyond its ANSI SQL datetime meaning.
Full prod backtrace:
Root Cause
utf8mb3character set only supports 1-3 byte UTF-8 charactersutf8(maps toutf8mb3) instead ofutf8mb4Steps to Reproduce
Fix
attributes.commenttoutf8mb4_unicode_ciutf8toutf8mb4Potential Similar Issues
Other columns that may have the same problem:
shadow_attributescommentutf8_binevent_blacklistscommentutf8_unicode_ciorg_blacklistscommentutf8_unicode_ciThese are NOT fixed by this PR but should be considered for future updates.
Testing
After applying the fix, the same curl command succeeds:
{ "Attribute": { "id": "1", "comment": "Testing emoji: 🇮 🇪 🇪 🇸 🇫 🇷 and regular emojis 😀 🎉" } }Questions