Skip to content

Decimal column type not stored correctly in _mysql_data_types_cache #122

@jeroenpf

Description

@jeroenpf

For decimal columns, the format of the type + modifier is decimal(x,y) where x is the length and y is the number of decimal places. The mysql_type column currently contains values like decimal(x,. This causes issues when trying to get a create statement:

CREATE TABLE wp_wc_order_operational_data (
	`id` bigint(20) unsigned PRIMARY KEY AUTO_INCREMENT NOT NULL,
	...
	`date_completed_gmt` datetime DEFAULT NULL,
	`shipping_tax_amount` decimal(26, DEFAULT NULL,
	`shipping_total_amount` decimal(26, DEFAULT NULL,
	`discount_tax_amount` decimal(26, DEFAULT NULL,
	`discount_total_amount` decimal(26, DEFAULT NULL,
	`recorded_sales` tinyint(1) DEFAULT NULL,
	KEY wp_wc_order_operational_data__order_key (order_key),
	UNIQUE KEY wp_wc_order_operational_data__order_id (order_id)
);

This can be fixed in the WP_SQLite_Translator::skip_mysql_data_type method. Here we consume exactly 3 tokens, which works only when there is a single value between the brackets (x). Instead, we should consume/skip tokens until we find the closing ) of the type modifier.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions