Merge branch 'DDC-1462'
This commit is contained in:
commit
54217bd4c6
@ -672,7 +672,10 @@ final class PersistentCollection implements Collection
|
|||||||
*/
|
*/
|
||||||
public function slice($offset, $length = null)
|
public function slice($offset, $length = null)
|
||||||
{
|
{
|
||||||
if (!$this->initialized && $this->association['fetch'] == Mapping\ClassMetadataInfo::FETCH_EXTRA_LAZY) {
|
if ( ! $this->initialized &&
|
||||||
|
! $this->isDirty &&
|
||||||
|
$this->association['fetch'] == Mapping\ClassMetadataInfo::FETCH_EXTRA_LAZY) {
|
||||||
|
|
||||||
return $this->em->getUnitOfWork()
|
return $this->em->getUnitOfWork()
|
||||||
->getCollectionPersister($this->association)
|
->getCollectionPersister($this->association)
|
||||||
->slice($this, $offset, $length);
|
->slice($this, $offset, $length);
|
||||||
|
@ -326,6 +326,27 @@ class ExtraLazyCollectionTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
|||||||
$this->assertEquals(4, count($user->groups));
|
$this->assertEquals(4, count($user->groups));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group DDC-1462
|
||||||
|
*/
|
||||||
|
public function testSliceOnDirtyCollection()
|
||||||
|
{
|
||||||
|
$user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId);
|
||||||
|
/* @var $user CmsUser */
|
||||||
|
|
||||||
|
$newGroup = new \Doctrine\Tests\Models\CMS\CmsGroup();
|
||||||
|
$newGroup->name = "Test4";
|
||||||
|
|
||||||
|
$user->addGroup($newGroup);
|
||||||
|
$this->_em->persist($newGroup);
|
||||||
|
|
||||||
|
$qc = $this->getCurrentQueryCount();
|
||||||
|
$groups = $user->groups->slice(0, 10);
|
||||||
|
|
||||||
|
$this->assertEquals(4, count($groups));
|
||||||
|
$this->assertEquals($qc + 1, $this->getCurrentQueryCount());
|
||||||
|
}
|
||||||
|
|
||||||
private function loadFixture()
|
private function loadFixture()
|
||||||
{
|
{
|
||||||
$user1 = new \Doctrine\Tests\Models\CMS\CmsUser();
|
$user1 = new \Doctrine\Tests\Models\CMS\CmsUser();
|
||||||
|
Loading…
Reference in New Issue
Block a user