You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
melody run --no-cache --trust -vvv https://gist.githubusercontent.com/1ed/2d9d639854e46100e1e33b9f560ca634/raw/b4799646726e8ca3171c0475153ec4eb620e2765/doctrine-persist-order.php
This does not work:
melody run --no-cache --trust -vvv https://gist.githubusercontent.com/1ed/2d9d639854e46100e1e33b9f560ca634/raw/b622c5628b0684074436e4f7207368efeb52fccc/doctrine-persist-order.php
PHP Fatal error: Uncaught PDOException: SQLSTATE[23000]: Integrity constraint violation: 19 NOT NULL constraint failed: Offer.request_id in /tmp/melody/af91efd8dad36b9b9221ff131a21f6571e2d9c20b16e821fe7cf34136042d3ef7/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:91
The difference is the usage of cascade persist or manual persist.
It has 2 entities Request and Offer. Request has many Offers and one latest offer, the Offer has a Request. Requests can be created without Offers so the latest offer can be null, but Offers can not be created without a Request. I use UUIDs, so all ids are pre-generated by constructor and available before persistence. Despite of this Doctrine thinks it should insert Offer before Request and not using the existing id, simply makes it null (https://github.com/doctrine/doctrine2/blob/v2.5.6/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php#L643-L650) because its not queued for insert at this time. I have to manually call persist on the request before on the offer to make it work. If I remove the $latestOffer property from the Request it also works without problems.
Is there something that controls the order of cascade persist? Do I something wrong or this is a known limitation or a bug?
Thanks!
The text was updated successfully, but these errors were encountered:
Ohh, great it seems it works in master. Will it be in the next 2.5 release or just in 2.6? Could you please give me a link to the PR or commit? Thanks!
I have a problem reproduced by this gist:
https://gist.github.com/1ed/2d9d639854e46100e1e33b9f560ca634 (You can run it with https://github.com/sensiolabs/melody if you want)
This version works:
This does not work:
The difference is the usage of cascade persist or manual persist.
It has 2 entities Request and Offer. Request has many Offers and one latest offer, the Offer has a Request. Requests can be created without Offers so the latest offer can be null, but Offers can not be created without a Request. I use UUIDs, so all ids are pre-generated by constructor and available before persistence. Despite of this Doctrine thinks it should insert Offer before Request and not using the existing id, simply makes it null (https://github.com/doctrine/doctrine2/blob/v2.5.6/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php#L643-L650) because its not queued for insert at this time. I have to manually call persist on the request before on the offer to make it work. If I remove the $latestOffer property from the Request it also works without problems.
Is there something that controls the order of cascade persist? Do I something wrong or this is a known limitation or a bug?
Thanks!
The text was updated successfully, but these errors were encountered: