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

[BUG]: "This database engine does not support upserts" but MySQL supports it #66

Closed
rafaucau opened this issue May 15, 2024 · 2 comments · Fixed by #68
Closed

[BUG]: "This database engine does not support upserts" but MySQL supports it #66

rafaucau opened this issue May 15, 2024 · 2 comments · Fixed by #68
Assignees
Labels
bug Something isn't working ready to deploy
Milestone

Comments

@rafaucau
Copy link
Contributor

rafaucau commented May 15, 2024

Describe the bug

When I try to use the upsert method, I get this error:

Fatal error: Uncaught RuntimeException: This database engine does not support upserts. in /var/www/vhosts/localhost/vendor/illuminate/database/Query/Grammars/Grammar.php:1206 Stack trace: #0 /var/www/vhosts/localhost/vendor/illuminate/database/Query/Builder.php(3646): Illuminate\Database\Query\Grammars\Grammar->compileUpsert() #1 /var/www/vhosts/localhost/vendor/illuminate/database/Eloquent/Builder.php(1086): Illuminate\Database\Query\Builder->upsert() #2 /var/www/vhosts/localhost/vendor/illuminate/support/Traits/ForwardsCalls.php(23): Illuminate\Database\Eloquent\Builder->upsert() #3 /var/www/vhosts/localhost/vendor/illuminate/database/Eloquent/Model.php(2334): Illuminate\Database\Eloquent\Model->forwardCallTo() #4 /var/www/vhosts/localhost/vendor/dbout/wp-orm/src/Orm/AbstractModel.php(85): Illuminate\Database\Eloquent\Model->__call() #5 /var/www/vhosts/localhost/vendor/illuminate/database/Eloquent/Model.php(2346): Dbout\WpOrm\Orm\AbstractModel->__call() #6 /var/www/vhosts/localhost/packages/plugins/****/includes/Admin.php(31): Illuminate\Database\Eloquent\Model::__callStatic() #7 /var/www/vhosts/localhost/html/wp/wp-includes/class-wp-hook.php(324): ****\Admin->***\{closure}() #8 /var/www/vhosts/localhost/html/wp/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters() #9 /var/www/vhosts/localhost/html/wp/wp-includes/plugin.php(517): WP_Hook->do_action() #10 /var/www/vhosts/localhost/html/wp/wp-admin/admin.php(259): do_action() #11 /var/www/vhosts/localhost/html/wp/wp-admin/edit.php(10): require_once('...') #12 {main} thrown in /var/www/vhosts/localhost/vendor/illuminate/database/Query/Grammars/Grammar.php on line 1206

Steps to reproduce the issue

  1. Create Model
  2. Try to use upsert method on it, for example:
TestStat::upsert(
	[[
		'test_id' => $test_id,
		'count' => 1,
	]],
	[ 'test_id' ],
	[ 'count' => Database::getInstance()->raw( 'count + 1' ) ]
);

Expected behavior

The upsert method should work, as MySQL / MariaDB supports it.

Your setup

  • WordPress Version: 6.5.3
  • Module version: 3.1.3
  • Are you using framework ?: Bedrock
  • Database: MariaDB 10.5

Additional context

This is implemented in MySqlGrammar:
https://github.com/illuminate/database/blob/c57f5c8d3e55d9c952a2ad5f432bcb1dc2d3322c/Query/Grammars/MySqlGrammar.php#L246-L269

But not in Grammar:
https://github.com/illuminate/database/blob/5a121a1507ea69dfd416a618415dada9dd4a50b4/Query/Grammars/Grammar.php#L1306

@rafaucau rafaucau added the bug Something isn't working label May 15, 2024
@dimitriBouteille
Copy link
Owner

Hello again @rafaucau

Thanks for opening this issue. I look to fix this bug as quickly as possible, you will be informed when it is done.

Best,

@dimitriBouteille
Copy link
Owner

Hi @rafaucau

The bug has been fixed in v3.2.0 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ready to deploy
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants