1
0
mirror of synced 2024-12-05 03:06:05 +03:00

Default Version Value identifier is always an array

This commit is contained in:
Asmir Mustafic 2015-02-03 00:11:42 +01:00 committed by Marco Pivetta
parent c9e66e464d
commit cb52782e5e
2 changed files with 15 additions and 13 deletions

View File

@ -281,8 +281,11 @@ class BasicEntityPersister implements EntityPersister
$stmt->execute();
if ($isPostInsertId) {
$id = $idGenerator->generate($this->em, $entity);
$postInsertIds[$id] = $entity;
$generatedId = $idGenerator->generate($this->em, $entity);
$id = array(
$this->class->identifier[0] => $generatedId
);
$postInsertIds[$generatedId] = $entity;
} else {
$id = $this->class->getIdentifierValues($entity);
}
@ -304,11 +307,11 @@ class BasicEntityPersister implements EntityPersister
* entities version field.
*
* @param object $entity
* @param mixed $id
* @param array $id
*
* @return void
*/
protected function assignDefaultVersionValue($entity, $id)
protected function assignDefaultVersionValue($entity, array $id)
{
$value = $this->fetchVersionValue($this->class, $id);
@ -319,11 +322,11 @@ class BasicEntityPersister implements EntityPersister
* Fetches the current version value of a versioned entity.
*
* @param \Doctrine\ORM\Mapping\ClassMetadata $versionedClass
* @param mixed $id
* @param array $id
*
* @return mixed
*/
protected function fetchVersionValue($versionedClass, $id)
protected function fetchVersionValue($versionedClass, array $id)
{
$versionField = $versionedClass->versionField;
$tableName = $this->quoteStrategy->getTableName($versionedClass, $this->platform);
@ -335,10 +338,6 @@ class BasicEntityPersister implements EntityPersister
. ' FROM ' . $tableName
. ' WHERE ' . implode(' = ? AND ', $identifier) . ' = ?';
if (!is_array($id)) {
$id = array($this->class->identifier[0] => $id);
}
$flatId = $this->identifierFlattener->flattenIdentifier($versionedClass, $id);
$value = $this->conn->fetchColumn($sql, array_values($flatId));

View File

@ -176,8 +176,11 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
$rootTableStmt->execute();
if ($isPostInsertId) {
$id = $idGenerator->generate($this->em, $entity);
$postInsertIds[$id] = $entity;
$generatedId = $idGenerator->generate($this->em, $entity);
$id = array(
$this->class->identifier[0] => $generatedId
);
$postInsertIds[$generatedId] = $entity;
} else {
$id = $this->em->getUnitOfWork()->getEntityIdentifier($entity);
}
@ -572,7 +575,7 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
/**
* {@inheritdoc}
*/
protected function assignDefaultVersionValue($entity, $id)
protected function assignDefaultVersionValue($entity, array $id)
{
$value = $this->fetchVersionValue($this->getVersionedClassMetadata(), $id);
$this->class->setFieldValue($entity, $this->class->versionField, $value);