Support multi-value column type modifiers for _mysql_data_types_cache#126
Conversation
|
Thanks for adding the test - are there any other steps that I could manually run on my end to confirm that the issue is fixed? |
|
The unit tests should cover this change but if you want to do it manually you could try: Create a site in Studio, replace the sqlite database integration plugin with a clone of this repo and branch and then install a plugin that uses enum and/or decimal fields. The woocommerce plugin will add tables with decimals and the redirection plugin will create tables with enums. After you installed those plugins, you can inspect the After that you can try and run a query using |
|
Thanks @jeroenpf! The PR looks good. |
…migrator (#312) 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_cache` table. 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](#126), columns with multiple type arguments like `decimal(26, 8)` were incorrectly stored as `decimal(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](b5a9fba), index definitions like `KEY timestamp (timestamp)` were incorrectly parsed and stored as column `KEY` with type `timestamp(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.
Fixes: #122
This fix will skip over tokens until it finds the closing bracket of the type modifier
)instead of consuming exactly 3. This should account for data types that support more than one value as a modifier, such as: enum, float, decimal, double.Additionally, I've added support for enums. There are plugins that use enum fields and it makes sense to convert those to text in SQLite.
Testing instructions
Confirm the tests pass