Merge pull request #1405 from taueres/master
EntityManager#getReference throw ORMException for unrecognized id
This commit is contained in:
commit
e7685c89da
@ -482,6 +482,11 @@ use Doctrine\Common\Util\ClassUtils;
|
||||
}
|
||||
|
||||
$sortedId[$identifier] = $id[$identifier];
|
||||
unset($id[$identifier]);
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
throw ORMException::unrecognizedIdentifierFields($class->name, array_keys($id));
|
||||
}
|
||||
|
||||
// Check identity map first, if its already in there just return it.
|
||||
@ -493,10 +498,6 @@ use Doctrine\Common\Util\ClassUtils;
|
||||
return $this->find($entityName, $sortedId);
|
||||
}
|
||||
|
||||
if ( ! is_array($sortedId)) {
|
||||
$sortedId = array($class->identifier[0] => $sortedId);
|
||||
}
|
||||
|
||||
$entity = $this->proxyFactory->getProxy($class->name, $sortedId);
|
||||
|
||||
$this->unitOfWork->registerManaged($entity, $sortedId, array());
|
||||
|
@ -296,7 +296,7 @@ class ORMException extends Exception
|
||||
|
||||
/**
|
||||
* @param string $className
|
||||
* @param string $fieldName
|
||||
* @param string[] $fieldNames
|
||||
*
|
||||
* @return ORMException
|
||||
*/
|
||||
|
@ -136,6 +136,12 @@ class CompositePrimaryKeyTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
$poi = $this->_em->find('Doctrine\Tests\Models\Navigation\NavPointOfInterest', array('key1' => 100));
|
||||
}
|
||||
|
||||
public function testUnrecognizedIdentifierFieldsOnGetReference()
|
||||
{
|
||||
$this->setExpectedException('Doctrine\ORM\ORMException', "Unrecognized identifier fields: 'key1'");
|
||||
$poi = $this->_em->getReference('Doctrine\Tests\Models\Navigation\NavPointOfInterest', array('lat' => 10, 'long' => 20, 'key1' => 100));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-1939
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user