DDC-1302 - Fix bug in XmlDriver not handling orphan removal
This commit is contained in:
parent
c34612b8e9
commit
816039f23f
@ -285,8 +285,8 @@ class XmlDriver extends AbstractFileDriver
|
||||
$mapping['cascade'] = $this->_getCascadeMappings($oneToOneElement->cascade);
|
||||
}
|
||||
|
||||
if (isset($oneToOneElement->{'orphan-removal'})) {
|
||||
$mapping['orphanRemoval'] = (bool)$oneToOneElement->{'orphan-removal'};
|
||||
if (isset($oneToOneElement['orphan-removal'])) {
|
||||
$mapping['orphanRemoval'] = (bool)$oneToOneElement['orphan-removal'];
|
||||
}
|
||||
|
||||
$metadata->mapOneToOne($mapping);
|
||||
@ -310,8 +310,8 @@ class XmlDriver extends AbstractFileDriver
|
||||
$mapping['cascade'] = $this->_getCascadeMappings($oneToManyElement->cascade);
|
||||
}
|
||||
|
||||
if (isset($oneToManyElement->{'orphan-removal'})) {
|
||||
$mapping['orphanRemoval'] = (bool)$oneToManyElement->{'orphan-removal'};
|
||||
if (isset($oneToManyElement['orphan-removal'])) {
|
||||
$mapping['orphanRemoval'] = (bool)$oneToManyElement['orphan-removal'];
|
||||
}
|
||||
|
||||
if (isset($oneToManyElement->{'order-by'})) {
|
||||
|
@ -186,6 +186,7 @@ abstract class AbstractMappingDriverTest extends \Doctrine\Tests\OrmTestCase
|
||||
$this->assertFalse($class->associationMappings['phonenumbers']['isCascadeRefresh']);
|
||||
$this->assertFalse($class->associationMappings['phonenumbers']['isCascadeDetach']);
|
||||
$this->assertFalse($class->associationMappings['phonenumbers']['isCascadeMerge']);
|
||||
$this->assertTrue($class->associationMappings['phonenumbers']['orphanRemoval']);
|
||||
|
||||
// Test Order By
|
||||
$this->assertEquals(array('number' => 'ASC'), $class->associationMappings['phonenumbers']['orderBy']);
|
||||
@ -328,7 +329,7 @@ class User
|
||||
public $address;
|
||||
|
||||
/**
|
||||
* @OneToMany(targetEntity="Phonenumber", mappedBy="user", cascade={"persist"})
|
||||
* @OneToMany(targetEntity="Phonenumber", mappedBy="user", cascade={"persist"}, orphanRemoval=true)
|
||||
* @OrderBy({"number"="ASC"})
|
||||
*/
|
||||
public $phonenumbers;
|
||||
@ -423,7 +424,7 @@ class User
|
||||
1 => 'persist',
|
||||
),
|
||||
'mappedBy' => 'user',
|
||||
'orphanRemoval' => false,
|
||||
'orphanRemoval' => true,
|
||||
'orderBy' =>
|
||||
array(
|
||||
'number' => 'ASC',
|
||||
|
@ -63,7 +63,7 @@ $metadata->mapOneToMany(array(
|
||||
1 => 'persist',
|
||||
),
|
||||
'mappedBy' => 'user',
|
||||
'orphanRemoval' => false,
|
||||
'orphanRemoval' => true,
|
||||
'orderBy' =>
|
||||
array(
|
||||
'number' => 'ASC',
|
||||
|
@ -39,7 +39,7 @@
|
||||
<join-column name="address_id" referenced-column-name="id" on-delete="CASCADE" on-update="CASCADE"/>
|
||||
</one-to-one>
|
||||
|
||||
<one-to-many field="phonenumbers" target-entity="Phonenumber" mapped-by="user">
|
||||
<one-to-many field="phonenumbers" target-entity="Phonenumber" mapped-by="user" orphan-removal="true">
|
||||
<cascade>
|
||||
<cascade-persist/>
|
||||
</cascade>
|
||||
|
@ -34,6 +34,7 @@ Doctrine\Tests\ORM\Mapping\User:
|
||||
oneToMany:
|
||||
phonenumbers:
|
||||
targetEntity: Phonenumber
|
||||
orphanRemoval: true
|
||||
mappedBy: user
|
||||
orderBy:
|
||||
number: ASC
|
||||
|
Loading…
x
Reference in New Issue
Block a user