mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
BasicEntityPersister & Composite keys #6466
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @tasselchof on GitHub (May 14, 2020).
I have an entity, which is linked to itself:
This entity has a composite key and as long as I have the second link in parent and parent = null, basic entity persister in function \Doctrine\ORM\Persisters\Entity\BasicEntityPersister::prepareUpdateData setting shop in main entity to null.
Little debug on the issue (I was checking how it is parsing each key inside prepareUpdateData):
!!!!!!!!!!!!!!!!!shop+++++++++++++++++Array
(
[products_product_offers] => Array
(
[id] => 1043186
[article] =>
[name] => Test
[type] => simple
[image] =>
[barcodes] => Array
(
)
)
!!!!!!!!!!!!!!!!!parent+++++++++++++++++Array
(
[products_product_offers] => Array
(
[id] => 1043186
[article] =>
[name] => Test
[type] => simple
[image] =>
[barcodes] => Array
(
)
)
!!!!!!!!!!!!!!!!!currency+++++++++++++++++Array
(
[products_product_offers] => Array
(
[id] => 1043186
[article] =>
[name] => Test
[type] => simple
[image] =>
[barcodes] => Array
(
)
)
@tasselchof commented on GitHub (May 20, 2020):
850d57e791/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php (L667)Here, when BasicEntityPersister iterating through fields it's rewriting shop_id (value is correct at the first step, on the second it's rewriting it because of the composite key).
@stakahashi commented on GitHub (May 27, 2020):
+1
@beberlei commented on GitHub (May 27, 2020):
Two times the same join column looks quite dangerous to me. I am not sure that Doctrine can handle this internally.
@tasselchof commented on GitHub (May 27, 2020):
There is no double join, it is one join with a composite key. We updated entity adding field "parent shop" and this is solved an issue. Generally, we just don't use this field in any selects (also, we are not using doctrine there anymore - we refactored this API to use native SQL).
@tasselchof commented on GitHub (May 27, 2020):
It can - this version (I am not sure, maybe 3.0 handling it) just don't have a check where the field is related to - to entity itself or to related. And if there is no parent inside cycle it is nullifying the main entity value (because an entity doesn't have parent).
It is written in docs, that Doctrine is supporting composite keys natively. It does support them. But there are limits.
I believe there should be an exception in this situation or property should be handled appropriate way =)
@beberlei commented on GitHub (May 27, 2020):
I don't understand, you are saying it can or it cannot handle it both in the same sentence.
@tasselchof commented on GitHub (May 27, 2020):
I mean that it potentially can handle this relation, but because of this issue it is not handling it an appropriate way.