1
0
mirror of synced 2025-02-21 22:53:15 +03:00

Merge branch 'PR39'

This commit is contained in:
Benjamin Eberlei 2011-05-01 00:18:22 +02:00
commit e3d2a0e293
2 changed files with 35 additions and 12 deletions

View File

@ -75,6 +75,10 @@ class ObjectHydrator extends AbstractHydrator
// Remember which associations are "fetch joined", so that we know where to inject
// collection stubs or proxies and where not.
if (isset($this->_rsm->relationMap[$dqlAlias])) {
if ( ! isset($this->_rsm->aliasMap[$this->_rsm->parentAliasMap[$dqlAlias]])) {
throw HydrationException::parentObjectOfRelationNotFound($dqlAlias, $this->_rsm->parentAliasMap[$dqlAlias]);
}
$sourceClassName = $this->_rsm->aliasMap[$this->_rsm->parentAliasMap[$dqlAlias]];
$sourceClass = $this->_getClassMetadata($sourceClassName);
$assoc = $sourceClass->associationMappings[$this->_rsm->relationMap[$dqlAlias]];

View File

@ -246,5 +246,24 @@ class NativeQueryTest extends \Doctrine\Tests\OrmFunctionalTestCase
$rsm->addRootEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsUser', 'u');
$rsm->addJoinedEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress', 'a', 'u', 'address');
}
/**
* @group PR-39
*/
public function testUnknownParentAliasThrowsException()
{
$rsm = new ResultSetMappingBuilder($this->_em);
$rsm->addRootEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsUser', 'u');
$rsm->addJoinedEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress', 'a', 'un', 'address', array('id' => 'a_id'));
$query = $this->_em->createNativeQuery('SELECT u.*, a.*, a.id AS a_id FROM cms_users u INNER JOIN cms_addresses a ON u.id = a.user_id WHERE u.username = ?', $rsm);
$query->setParameter(1, 'romanb');
$this->setExpectedException(
"Doctrine\ORM\Internal\Hydration\HydrationException",
"The parent object of entity result with alias 'a' was not found. The parent alias is 'un'."
);
$users = $query->getResult();
}
}