Closed rafaucau closed 4 months ago
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
upsert
TestStat::upsert( [[ 'test_id' => $test_id, 'count' => 1, ]], [ 'test_id' ], [ 'count' => Database::getInstance()->raw( 'count + 1' ) ] );
The upsert method should work, as MySQL / MariaDB supports it.
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
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,
Hi @rafaucau
The bug has been fixed in v3.2.0 :rocket:
Describe the bug
When I try to use the upsert method, I get this error:
Steps to reproduce the issue
upsert
method on it, for example:Expected behavior
The
upsert
method should work, as MySQL / MariaDB supports it.Your setup
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