Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multi-value column type modifiers for _mysql_data_types_cache #126

Merged

Conversation

jeroenpf
Copy link
Contributor

@jeroenpf jeroenpf commented Jul 17, 2024

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

@katinthehatsite
Copy link

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?

@jeroenpf
Copy link
Contributor Author

@katinthehatsite

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 _mysql_data_types_cache table and ensure that the columns that have decimal or enum types are properly represented in that table.

After that you can try and run a query using $wpdb->query('SHOW CREATE table);` and see if it outputs a valid MySQL-compatible create statement.

@bgrgicak
Copy link
Collaborator

Thanks @jeroenpf! The PR looks good.

@bgrgicak bgrgicak merged commit d24fff8 into WordPress:main Jul 18, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Decimal column type not stored correctly in _mysql_data_types_cache
3 participants