Commit fdd9b051 authored by romanb's avatar romanb

[2.0] Fix for optimistic locking.

parent ba4d1bb3
......@@ -588,7 +588,6 @@ class EntityManager
*
* @param mixed $conn An array with the connection parameters or an existing
* Connection instance.
* @param string $name The name of the EntityManager.
* @param Configuration $config The Configuration instance to use.
* @param EventManager $eventManager The EventManager instance to use.
* @return EntityManager The created EntityManager.
......
......@@ -49,16 +49,16 @@ class Assigned extends AbstractIdGenerator
foreach ($idFields as $idField) {
$value = $class->getReflectionProperty($idField)->getValue($entity);
if (isset($value)) {
$identifier[] = $value;
$identifier[$idField] = $value;
} else {
throw ORMException::entityMissingAssignedId($entity);
}
}
} else {
$value = $class->getReflectionProperty($class->getSingleIdentifierFieldName())
->getValue($entity);
$idField = $class->identifier[0];
$value = $class->reflFields[$idField]->getValue($entity);
if (isset($value)) {
$identifier[] = $value;
$identifier[$idField] = $value;
} else {
throw ORMException::entityMissingAssignedId($entity);
}
......
......@@ -183,7 +183,7 @@ class StandardEntityPersister
//FIXME: Order with composite keys might not be correct
$sql = "SELECT " . $versionFieldColumnName . " FROM " . $class->getQuotedTableName($this->_platform) .
" 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);
}
......
......@@ -42,13 +42,13 @@ class AssignedIdTest extends \Doctrine\Tests\OrmTestCase
$entity = new AssignedSingleIdEntity;
$entity->myId = 1;
$id = $this->_assignedGen->generate($this->_em, $entity);
$this->assertEquals(array(1), $id);
$this->assertEquals(array('myId' => 1), $id);
$entity = new AssignedCompositeIdEntity;
$entity->myId2 = 2;
$entity->myId1 = 4;
$id = $this->_assignedGen->generate($this->_em, $entity);
$this->assertEquals(array(4, 2), $id);
$this->assertEquals(array('myId1' => 4, 'myId2' => 2), $id);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment