Repository navigation
fix(mysql): read and compare text as utf8mb4; pre-scan sees collation, comment, generated - #268
Merged
Merged
Conversation
…, comment, generated DBDiff connected to MySQL as utf8 (utf8mb3) and compared rows cast to it, so a four-byte character — an emoji, a script outside the Basic Multilingual Plane — read as '?', and a change between two of them was not seen. The schema pre-scan left out a column's character set, collation, comment and generated expression, so a table differing only there was skipped as unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
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.



Found by testing multilingual data (Gurmukhi, transliterations, translations in Hindi, Urdu and Chinese, emoji, Brahmi) under mixed column, table and database collations on MySQL 8.0 and Dolt 2.2.3.
1. Four-byte characters: changes were silently missed (both data paths)
utf8, which in MySQL isutf8mb3(at most three bytes a character).CAST(… AS CHAR CHARACTER SET utf8)/CONVERT(… USING utf8).?. So🙏 → 🙂or𑀅𑀓 → 𑀅𑀔produced no migration at all.utf8mb4/utf8mb4_unicode_ci, and every comparison casts toutf8mb4. (The migration runner's MySQL connection already usedutf8mb4.)2. The schema pre-scan skipped real changes
utf8mb4_unicode_citoutf8mb4_0900_ai_ci, a changed column comment, or a changedGENERATED ALWAYS AS.Verified to work, byte for byte, same-server and cross-server
latin1columns, and table-level collation changes.New test:
tests/DataDiff/UnicodeMySQLTest.php(MySQL and Dolt jobs). All three cases fail onmasterand pass here.HEXof every value), collations included.Dolt quirks found (not DBDiff bugs); the test accounts for both:
UPDATEthat changes only case in a case-insensitive column ("0 rows affected"), so on Dolt the test checks the planned SQL rather than the applied bytes.information_schema.COLUMNS.GENERATION_EXPRESSIONempty, so the pre-scan can't see a generated-expression-only change there.Not fixable in DBDiff: MySQL stores column comments in
utf8mb3, so an emoji in a comment is already?in MySQL itself.Locally, all passing:
DBDiff,UnitDBDiff,Unit🤖 Generated with Claude Code