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;
|
$association = $assoc;
|
||||||
$joinCondition = array();
|
$joinCondition = array();
|
||||||
|
|
||||||
|
if (isset($assoc['indexBy'])) {
|
||||||
|
$this->rsm->addIndexBy($assocAlias, $assoc['indexBy']);
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! $assoc['isOwningSide']) {
|
if ( ! $assoc['isOwningSide']) {
|
||||||
$eagerEntity = $this->em->getClassMetadata($assoc['targetEntity']);
|
$eagerEntity = $this->em->getClassMetadata($assoc['targetEntity']);
|
||||||
$association = $eagerEntity->getAssociationMapping($assoc['mappedBy']);
|
$association = $eagerEntity->getAssociationMapping($assoc['mappedBy']);
|
||||||
|
@ -39,10 +39,12 @@ class DDC440Test extends \Doctrine\Tests\OrmFunctionalTestCase
|
|||||||
$client->setName('Client1');
|
$client->setName('Client1');
|
||||||
|
|
||||||
$phone = new DDC440Phone;
|
$phone = new DDC440Phone;
|
||||||
|
$phone->setId(1);
|
||||||
$phone->setNumber('418 111-1111');
|
$phone->setNumber('418 111-1111');
|
||||||
$phone->setClient($client);
|
$phone->setClient($client);
|
||||||
|
|
||||||
$phone2 = new DDC440Phone;
|
$phone2 = new DDC440Phone;
|
||||||
|
$phone->setId(2);
|
||||||
$phone2->setNumber('418 222-2222');
|
$phone2->setNumber('418 222-2222');
|
||||||
$phone2->setClient($client);
|
$phone2->setClient($client);
|
||||||
|
|
||||||
@ -56,8 +58,9 @@ class DDC440Test extends \Doctrine\Tests\OrmFunctionalTestCase
|
|||||||
$uw = $this->_em->getUnitOfWork();
|
$uw = $this->_em->getUnitOfWork();
|
||||||
$client = $this->_em->find('Doctrine\Tests\ORM\Functional\Ticket\DDC440Client', $id);
|
$client = $this->_em->find('Doctrine\Tests\ORM\Functional\Ticket\DDC440Client', $id);
|
||||||
$clientPhones = $client->getPhones();
|
$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.
|
// 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
|
// 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;
|
protected $main_phone;
|
||||||
/**
|
/**
|
||||||
* @OneToMany(targetEntity="DDC440Phone", mappedBy="client", cascade={"persist", "remove"}, fetch="EAGER")
|
* @OneToMany(targetEntity="DDC440Phone", mappedBy="client", cascade={"persist", "remove"}, fetch="EAGER", indexBy="id")
|
||||||
* @orderBy({"number"="ASC"})
|
* @OrderBy({"number"="ASC"})
|
||||||
*/
|
*/
|
||||||
protected $phones;
|
protected $phones;
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user