Added index by consideration when eagerly loading to-many associations.
This commit is contained in:
parent
13afde0140
commit
54898eca60
@ -1192,6 +1192,10 @@ class BasicEntityPersister implements EntityPersister
|
||||
$association = $assoc;
|
||||
$joinCondition = array();
|
||||
|
||||
if (isset($assoc['indexBy'])) {
|
||||
$this->rsm->addIndexBy($assocAlias, $assoc['indexBy']);
|
||||
}
|
||||
|
||||
if ( ! $assoc['isOwningSide']) {
|
||||
$eagerEntity = $this->em->getClassMetadata($assoc['targetEntity']);
|
||||
$association = $eagerEntity->getAssociationMapping($assoc['mappedBy']);
|
||||
|
@ -39,10 +39,12 @@ class DDC440Test extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
$client->setName('Client1');
|
||||
|
||||
$phone = new DDC440Phone;
|
||||
$phone->setId(1);
|
||||
$phone->setNumber('418 111-1111');
|
||||
$phone->setClient($client);
|
||||
|
||||
$phone2 = new DDC440Phone;
|
||||
$phone->setId(2);
|
||||
$phone2->setNumber('418 222-2222');
|
||||
$phone2->setClient($client);
|
||||
|
||||
@ -56,8 +58,9 @@ class DDC440Test extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
$uw = $this->_em->getUnitOfWork();
|
||||
$client = $this->_em->find('Doctrine\Tests\ORM\Functional\Ticket\DDC440Client', $id);
|
||||
$clientPhones = $client->getPhones();
|
||||
$p1 = $clientPhones[0];
|
||||
$p2 = $clientPhones[1];
|
||||
|
||||
$p1 = $clientPhones[1];
|
||||
$p2 = $clientPhones[2];
|
||||
|
||||
// Test the first phone. The assertion actually failed because original entity data is not set properly.
|
||||
// This was because it is also set as MainPhone and that one is created as a proxy, not the
|
||||
@ -156,8 +159,8 @@ class DDC440Client
|
||||
*/
|
||||
protected $main_phone;
|
||||
/**
|
||||
* @OneToMany(targetEntity="DDC440Phone", mappedBy="client", cascade={"persist", "remove"}, fetch="EAGER")
|
||||
* @orderBy({"number"="ASC"})
|
||||
* @OneToMany(targetEntity="DDC440Phone", mappedBy="client", cascade={"persist", "remove"}, fetch="EAGER", indexBy="id")
|
||||
* @OrderBy({"number"="ASC"})
|
||||
*/
|
||||
protected $phones;
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user