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

Queries with INSERT INGORE are not working? #79

Open
remcotolsma opened this issue Mar 26, 2024 · 0 comments
Open

Queries with INSERT INGORE are not working? #79

remcotolsma opened this issue Mar 26, 2024 · 0 comments

Comments

@remcotolsma
Copy link

remcotolsma commented Mar 26, 2024

We use the following query to convert WordPress user meta data to a custom table in a plugin:

INSERT IGNORE INTO wp_pronamic_pay_mollie_customers (
	mollie_id,
	test_mode
)
SELECT
	meta_value AS mollie_id,
	'_pronamic_pay_mollie_customer_id_test' = meta_key AS test_mode
FROM
	wp_usermeta
WHERE
	meta_key IN (
		'_pronamic_pay_mollie_customer_id',
		'_pronamic_pay_mollie_customer_id_test'
	)
		AND
	meta_value != ''
;

https://github.com/pronamic/wp-pronamic-pay-mollie/blob/82f0e72fedfdc11f706de64442a7f43c4ac96a62/src/Install.php#L313-L331

This results in the following error:

localhost_8881_wp-admin_admin php_page=pronamic_ideal

I think we can rewrite the query so the IGNORE is no longer needed.

Also INSERT OR IGNORE seems te work:

INSERT OR IGNORE INTO wp_pronamic_pay_mollie_customers (
	mollie_id,
	test_mode
)
SELECT
	meta_value AS mollie_id,
	'_pronamic_pay_mollie_customer_id_test' = meta_key AS test_mode
FROM
	wp_usermeta
WHERE
	meta_key IN (
		'_pronamic_pay_mollie_customer_id',
		'_pronamic_pay_mollie_customer_id_test'
	)
		AND
	meta_value != ''
;

https://stackoverflow.com/questions/12105198/sqlite-how-to-get-insert-or-ignore-to-work

This project is new to me, I have no idea if the SQL parser in this plugin should or could correct this.

Table prefix	wp_
Database type	SQLite
SQLite version	3.40.1
Database file	/var/www/html/wp-content/database/.ht.sqlite
Database size	532 KB
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant