Handle incorrectly stored MySQL metadata in the legacy-to-AST driver migrator #312
+148
−0
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.
When migrating from the legacy SQLite driver to the new AST-based driver, the information schema reconstructor reads MySQL column type metadata from the
_mysql_data_types_cachetable. Some older versions of the legacy driver stored invalid type definitions in this table, causing migration failures.This PR detects and handles two types of invalid data:
1. Truncated decimal definitions — Before PR #126, columns with multiple type arguments like
decimal(26, 8)were incorrectly stored asdecimal(26,(missing the second argument and closing parenthesis). For WooCommerce tables, the fix restores the correct decimal precision based on known WooCommerce column patterns. For other tables, these invalid definitions are discarded and the column type is inferred from SQLite.2. Index definitions mistaken for columns — Before commit b5a9fba, index definitions like
KEY timestamp (timestamp)were incorrectly parsed and stored as columnKEYwith typetimestamp(timestamp). The fix validates that type arguments are numeric, rejecting these malformed entries and falling back to the SQLite type inference.Fixes WordPress/wordpress-playground#3050.