Open
Description
Description
When doing a save operation with associations, the error message on the assocs can be hidden completely.
$data['orders'] = ['_ids' => $orderIds];
$data['deposits'] = ['_ids' => $depositIds];
$invoice = $this->Invoices->patchEntity($invoice, $data);
if ($this->Invoices->save($invoice, ['associated' => ['Orders', 'Deposits']])) {
Just returns false, nothing else. Even a saveOrFail() here would only return
Cake\ORM\Exception\PersistenceFailedException: Entity save failure.
After a lot of debugging, setting 'atomic' => false
into it revealed the message suddenly:
Cake\ORM\Exception\PersistenceFailedException: Entity save failure. Found the following errors (orders.0._joinData.order_id._isUnique: "This value is already in use").
/vendor/cakephp/cakephp/src/ORM/Table.php:1985
I wonder if there isnt a better way of combining assoc issues into the primary error, so the actual issue is visible for local dev and debugging, but also when logging e.g. on prod.
Right now, with default atomic true those would always be invisible it seems.
CakePHP Version
5.0
PHP Version
8.3