[2.0] Fix for optimistic locking.
This commit is contained in:
parent
ba4d1bb393
commit
fdd9b05158
@ -588,7 +588,6 @@ class EntityManager
|
|||||||
*
|
*
|
||||||
* @param mixed $conn An array with the connection parameters or an existing
|
* @param mixed $conn An array with the connection parameters or an existing
|
||||||
* Connection instance.
|
* Connection instance.
|
||||||
* @param string $name The name of the EntityManager.
|
|
||||||
* @param Configuration $config The Configuration instance to use.
|
* @param Configuration $config The Configuration instance to use.
|
||||||
* @param EventManager $eventManager The EventManager instance to use.
|
* @param EventManager $eventManager The EventManager instance to use.
|
||||||
* @return EntityManager The created EntityManager.
|
* @return EntityManager The created EntityManager.
|
||||||
|
@ -49,16 +49,16 @@ class Assigned extends AbstractIdGenerator
|
|||||||
foreach ($idFields as $idField) {
|
foreach ($idFields as $idField) {
|
||||||
$value = $class->getReflectionProperty($idField)->getValue($entity);
|
$value = $class->getReflectionProperty($idField)->getValue($entity);
|
||||||
if (isset($value)) {
|
if (isset($value)) {
|
||||||
$identifier[] = $value;
|
$identifier[$idField] = $value;
|
||||||
} else {
|
} else {
|
||||||
throw ORMException::entityMissingAssignedId($entity);
|
throw ORMException::entityMissingAssignedId($entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$value = $class->getReflectionProperty($class->getSingleIdentifierFieldName())
|
$idField = $class->identifier[0];
|
||||||
->getValue($entity);
|
$value = $class->reflFields[$idField]->getValue($entity);
|
||||||
if (isset($value)) {
|
if (isset($value)) {
|
||||||
$identifier[] = $value;
|
$identifier[$idField] = $value;
|
||||||
} else {
|
} else {
|
||||||
throw ORMException::entityMissingAssignedId($entity);
|
throw ORMException::entityMissingAssignedId($entity);
|
||||||
}
|
}
|
||||||
|
@ -183,7 +183,7 @@ class StandardEntityPersister
|
|||||||
//FIXME: Order with composite keys might not be correct
|
//FIXME: Order with composite keys might not be correct
|
||||||
$sql = "SELECT " . $versionFieldColumnName . " FROM " . $class->getQuotedTableName($this->_platform) .
|
$sql = "SELECT " . $versionFieldColumnName . " FROM " . $class->getQuotedTableName($this->_platform) .
|
||||||
" WHERE " . implode(' = ? AND ', $identifier) . " = ?";
|
" WHERE " . implode(' = ? AND ', $identifier) . " = ?";
|
||||||
$value = $this->_conn->fetchColumn($sql, array_values($id));
|
$value = $this->_conn->fetchColumn($sql, array_values((array)$id));
|
||||||
$this->_class->setFieldValue($entity, $versionField, $value);
|
$this->_class->setFieldValue($entity, $versionField, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,13 +42,13 @@ class AssignedIdTest extends \Doctrine\Tests\OrmTestCase
|
|||||||
$entity = new AssignedSingleIdEntity;
|
$entity = new AssignedSingleIdEntity;
|
||||||
$entity->myId = 1;
|
$entity->myId = 1;
|
||||||
$id = $this->_assignedGen->generate($this->_em, $entity);
|
$id = $this->_assignedGen->generate($this->_em, $entity);
|
||||||
$this->assertEquals(array(1), $id);
|
$this->assertEquals(array('myId' => 1), $id);
|
||||||
|
|
||||||
$entity = new AssignedCompositeIdEntity;
|
$entity = new AssignedCompositeIdEntity;
|
||||||
$entity->myId2 = 2;
|
$entity->myId2 = 2;
|
||||||
$entity->myId1 = 4;
|
$entity->myId1 = 4;
|
||||||
$id = $this->_assignedGen->generate($this->_em, $entity);
|
$id = $this->_assignedGen->generate($this->_em, $entity);
|
||||||
$this->assertEquals(array(4, 2), $id);
|
$this->assertEquals(array('myId1' => 4, 'myId2' => 2), $id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user