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