Closed doctrinebot closed 8 years ago
Comment created by petr_motejlek:
I just found out, that when I have an entity containing a *ToMany column with cascade={"remove"} set, all the entities are removed, except for the one...
Comment created by @beberlei:
I cannot reproduce this issue. Can you try to build a reproducible test-case? Have a look at tests/Doctrine/Tests/ORM/Functional/Ticket/* and build a test-case like this one here:
<?php
namespace Doctrine\Tests\ORM\Functional\Ticket;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Tests\Models\CMS\CmsUser;
use Doctrine\Tests\Models\CMS\CmsGroup;
require*once __DIR_* . '/../../../TestInit.php';
class DDC824Test extends \Doctrine\Tests\OrmFunctionalTestCase
{
public function setUp()
{
$this->useModelSet('cms');
parent::setUp();
}
public function testRemoveWithCascade()
{
$user = new CmsUser();
$user->username = "beberlei";
$user->name = "Benjamin";
$user->status = "active";
$phone1 = new \Doctrine\Tests\Models\CMS\CmsPhonenumber();
$phone1->phonenumber = "1234";
$phone2 = new \Doctrine\Tests\Models\CMS\CmsPhonenumber();
$phone2->phonenumber = "1235";
$user->addPhonenumber($phone1);
$user->addPhonenumber($phone2);
$this->_em->persist($user);
$this->_em->flush();
$this->_em->clear();
$user = $this->*em->find(get*class($user), $user->id);
$phone1 = $user->phonenumbers[0];
$phone2 = $user->phonenumbers[1];
$this->assertTrue($this->_em->contains($user));
$this->assertTrue($this->_em->contains($phone1));
$this->assertTrue($this->_em->contains($phone2));
$this->_em->remove($user);
$this->assertFalse($this->_em->contains($user));
$this->assertFalse($this->_em->contains($phone1));
$this->assertFalse($this->_em->contains($phone2));
}
}
Comment created by petr_motejlek:
I found out that I cannot reproduce the same behaviour with different project of mine either. It seems there's simply something rotten inside the one. I'll try investigating it a bit farther, but I think you can close this issue for now. Thanks for your time ;).
Issue was closed with resolution "Invalid"
Jira issue originally created by user petr_motejlek:
The upper code won't remove the entity from the database.... Corresponding DQL (DELETE ProductAttribute a WHERE a.id = 1) will remove it from the database...