DDC-3017: UnitOfWork::$entityIdentifiers does not get updated when saving composite PK with a JoinColum as PK #3784

Closed
doctrinebot opened this Issue Mar 8, 2014 · 6 comments

2 participants

@doctrinebot

Jira issue originally created by user rande:

The Sonata Admin Bundle rely on the UnitOfWork::getEntityIdentifier method to retrieve the object identifier.

We are adding support for composite PK with a FK as described in the gist: https://gist.github.com/rande/9439778 .

The bug occurs when the Material reference is updated on the Color object. The Color has a new set of PK. However the UnitOfWork::$entityIdentifiers is not updated when the object is persisted. So the values stored UnitOfWork::$entityIdentifiers are invalid for the Color object.

The consequence is that we are unable to redirect the user once the object is saved as the UnitOfWork::getEntityIdentifier refers to the old values.

@doctrinebot

Comment created by @ocramius:

[~rande] can you please come up with a failing test case for this issue?

@doctrinebot

Comment created by @beberlei:

It is not supported to change the identifier. They are assumed to be immutable by Doctrine and we cannot change that, as the consequences are impossible to handle.

@doctrinebot

Issue was closed with resolution "Won't Fix"

@doctrinebot

Comment created by rande:

Thanks for commenting this issue. So with composite keys the assumption is wrong and from your comment this bug is the expected behavior.

Now, should doctrine provide a secure method to retrieve the identifier keys ?

@doctrinebot

Comment created by @ocramius:

[~rande] shouldn't you extract identifiers via metadata by having an instance of an entity?

@doctrinebot

Comment created by rande:

It is what I did: https://github.com/sonata-project/SonataDoctrineORMAdminBundle/blob/master/Model/ModelManager.php#L277-L303

However it will be better to have a clean implementation in the ORM.

@beberlei beberlei was assigned by doctrinebot Dec 6, 2015
@doctrinebot doctrinebot closed this Dec 6, 2015
@doctrinebot doctrinebot added the Bug label Dec 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment