This commit is contained in:
parent
0a86c324ad
commit
e736d19677
@ -887,14 +887,7 @@ class UnitOfWork implements PropertyChangedListener
|
|||||||
$idValue = $idGen->generate($this->em, $entity);
|
$idValue = $idGen->generate($this->em, $entity);
|
||||||
|
|
||||||
if ( ! $idGen instanceof \Doctrine\ORM\Id\AssignedGenerator) {
|
if ( ! $idGen instanceof \Doctrine\ORM\Id\AssignedGenerator) {
|
||||||
$idField = $class->identifier[0];
|
$idValue = [$class->getSingleIdentifierFieldName() => $this->convertSingleFieldIdentifierToPHPValue($class, $idValue)];
|
||||||
|
|
||||||
$idValue = [
|
|
||||||
$idField => $this->em->getConnection()->convertToPHPValue(
|
|
||||||
$idValue,
|
|
||||||
$class->getTypeOfField($idField)
|
|
||||||
)
|
|
||||||
];
|
|
||||||
|
|
||||||
$class->setIdentifierValues($entity, $idValue);
|
$class->setIdentifierValues($entity, $idValue);
|
||||||
}
|
}
|
||||||
@ -1012,11 +1005,8 @@ class UnitOfWork implements PropertyChangedListener
|
|||||||
if ($postInsertIds) {
|
if ($postInsertIds) {
|
||||||
// Persister returned post-insert IDs
|
// Persister returned post-insert IDs
|
||||||
foreach ($postInsertIds as $postInsertId) {
|
foreach ($postInsertIds as $postInsertId) {
|
||||||
$idField = $class->identifier[0];
|
$idField = $class->getSingleIdentifierFieldName();
|
||||||
$idValue = $this->em->getConnection()->convertToPHPValue(
|
$idValue = $this->convertSingleFieldIdentifierToPHPValue($class, $postInsertId['generatedId']);
|
||||||
$postInsertId['generatedId'],
|
|
||||||
$class->getTypeOfField($idField)
|
|
||||||
);
|
|
||||||
|
|
||||||
$entity = $postInsertId['entity'];
|
$entity = $postInsertId['entity'];
|
||||||
$oid = spl_object_hash($entity);
|
$oid = spl_object_hash($entity);
|
||||||
@ -3475,4 +3465,20 @@ class UnitOfWork implements PropertyChangedListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ClassMetadata $class
|
||||||
|
* @param mixed $identifierValue
|
||||||
|
*
|
||||||
|
* @return mixed the identifier after type conversion
|
||||||
|
*
|
||||||
|
* @throws \Doctrine\ORM\Mapping\MappingException if the entity has more than a single identifier
|
||||||
|
*/
|
||||||
|
private function convertSingleFieldIdentifierToPHPValue(ClassMetadata $class, $identifierValue)
|
||||||
|
{
|
||||||
|
return $this->em->getConnection()->convertToPHPValue(
|
||||||
|
$identifierValue,
|
||||||
|
$class->getTypeOfField($class->getSingleIdentifierFieldName())
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user