Fix TEXT column variants not round-tripping correctly#1032
Conversation
When using migration_diff, TEXT column variants (TINYTEXT, MEDIUMTEXT, LONGTEXT) were not being properly mapped back from the database. The BLOB type handling already used rawType to distinguish BLOB variants, but TEXT variants were missing equivalent handling. This adds similar rawType-based mapping for TEXT columns in mapColumnType() and includes round-trip tests. Fixes #1029
CI Failures NoteThe CI failures on MySQL/MariaDB are unrelated to this PR. They are pre-existing issues:
The 5.x branch CI passed 4 days ago with the same test matrix. These failures appear to be caused by recent dependency updates or test flakiness. My changes only modify |
|
CI failures are likely not relevant, see #1034 |
1 similar comment
|
CI failures are likely not relevant, see #1034 |
| ['text', null, 'text', null], | ||
| ['text', MysqlAdapter::TEXT_TINY, 'text', MysqlAdapter::TEXT_TINY], | ||
| ['text', MysqlAdapter::TEXT_MEDIUM, 'text', MysqlAdapter::TEXT_MEDIUM], | ||
| ['text', MysqlAdapter::TEXT_LONG, 'text', MysqlAdapter::TEXT_LONG], |
There was a problem hiding this comment.
Do you need all four? Wouldn't one pair suffice?
There was a problem hiding this comment.
Can it be reduced? Yes, technically. The code paths are symmetric.
Downsides of reducing:
- Each is a genuinely different MySQL column type with different storage characteristics
- If someone modifies the constants or the mapping, a missing test case could let a regression slip through
- It's testing 4 branches in that match statement - reducing means less branch coverage
There was a problem hiding this comment.
I was thinking of the duplication in the parameter lists. The number of scenarios seems required. In any case it doesn't need to be a blocker.
Summary
mapColumnType()to properly distinguish TINYTEXT, MEDIUMTEXT, and LONGTEXT variantsFixes #1029
Problem
When using
migration_diff, TEXT column variants (TINYTEXT, MEDIUMTEXT, LONGTEXT) were not being properly mapped back from the database. The code already handled BLOB variants correctly by checking the raw MySQL type string, but TEXT variants were missing equivalent handling.For example, a LONGTEXT column would:
rawType='longtext'andlength=4294967295mapColumnData()where 4294967295 didn't match any caseSolution
Added equivalent rawType-based handling for TEXT columns in
mapColumnType():tinytext→TEXT_TINY(255)mediumtext→TEXT_MEDIUM(16777215)longtext→TEXT_LONG(2147483647)text→null(default TEXT)