WPIntell

Source evidence

ON DUPLICATE KEY UPDATE translation issue

SQLite Database Integration · support · 2023-12-01T11:44:00+00:00

complaintsentiment
highseverity
1.0relevance
2replies
Evidence linked to opportunitycommercial context

Proof Health

Open evidence

Commercial opportunities need traceable source links before they are treated as build-worthy.

4 / 31 rows with source links

12.9% of this page's analysis has direct source links.

0 build-decision rows missing links

0 rows here require auditable proof before promotion.

27 rows with no attached evidence

0 rows have source counts but still need direct links.

Conversation

support
vendidero unresolved
Hi there, I was currently testing the WP playground implementation which is using this plugin to store the db. I’ve discovered an issue with a query used by WooCommerce to update/create orders: INSERT INTO wp_wc_orders ( billing_email , currency , customer_id , customer_note , date_created_gmt , date_updated_gmt , id , ip_address , parent_order_id , payment_method , payment_method_title , status , tax_amount , total_amount , transaction_id , type , user_agent ) VALUES ( 'info@test.com', 'EUR', 1, '', '2023-12-01 11:20:31', '2023-12-01 11:20:31', 33, '::1', 0, '', '', 'wc-checkout-draft', 1.596639, 0.000000, '', 'shop_order', 'test' ) on duplicate KEYUPDATE billing_email =VALUES ( billing_email ) , currency =VALUES ( currency ) , customer_id =VALUES ( customer_id ) , customer_note =VALUES ( customer_note ) , date_created_gmt =VALUES ( date_created_gmt ) , date_updated_gmt =VALUES ( date_updated_gmt ) , id =VALUES ( id ) , ip_address =VALUES ( ip_address ) , parent_order_id =VALUES ( parent_order_id ) , payment_method =VALUES ( payment_method ) , payment_method_title =VALUES ( payment_method_title ) , status =VALUES ( status ) , tax_amount =VALUES ( tax_amount ) , total_amount =VALUES ( total_amount ) , transaction_id =VALUES ( transaction_id ) , type =VALUES ( type ) , user_agent =VALUES ( user_agent ) This gets translated to the following SQLite query: INSERT INTO wp_wc_orders ( billing_email , currency , customer_id , customer_note , date_created_gmt , date_updated_gmt , id , ip_address , parent_order_id , payment_method , payment_method_title , status , tax_amount , total_amount , transaction_id , type , user_agent ) VALUES ( :param0 , :param1 , 1, :param2 , :param3 , :param4 , 40, :param5 , 0, :param6 , :param7 , :param8 , 1.596639, 0.000000, :param9 , :param10 , :param11 ) ON CONFLICT ("id", ) DO UPDATE SET billing_email = excluded. billing_email , currency = excluded. currency , customer_id = excluded. customer_id , customer_note = excluded. customer_note , date_created_gmt = excluded. date_created_gmt , date_updated_gmt = excluded. date_updated_gmt , id = excluded. id , ip_address = excluded. ip_address , parent_order_id = excluded. parent_order_id , payment_method = excluded. payment_method , payment_method_title = excluded. payment_method_title , status = excluded. status , tax_amount = excluded. tax_amount , total_amount = excluded. total_amount , transaction_id = excluded. transaction_id , type = excluded. type , user_agent = excluded. user_agent The issue is the ON CONFLICT ("id", ) DO UPDATE SET line. This issue is due to a missing array key reset in the WP_SQLite_Translator::translate_on_duplicate_key() method. Adding an additional: /** * Reset array keys to prevent parsing issues. */ $conflict_columns = array_values( $conflict_columns ); After parsing the columns fixes the issue. Best, Dennis Many thanks for the insights @vendidero . I’ll pass this information on to the team and we can report back to you here with an update. @vendidero Just to let you know that after some checks with WooCommerce based on your query, we were able to replicate some potential issues. As there is an open GitHub issue similar to this, you may wish to include the above as a comment to that issue: https://github.com/WordPress/sqlite-database-integration/issues/19

Comments

2 shown
James Osborne 2023-12-01T17:25:00+00:00

Many thanks for the insights @vendidero . I’ll pass this information on to the team and we can report back to you here with an update.

James Osborne 2023-12-05T09:55:00+00:00

@vendidero Just to let you know that after some checks with WooCommerce based on your query, we were able to replicate some potential issues. As there is an open GitHub issue similar to this, you may wish to include the above as a comment to that issue: https://github.com/WordPress/sqlite-database-integration/issues/19