1
0
mirror of synced 2025-01-29 19:41:45 +03:00

DDC-762 - Fixed notice when mapping foreign keys to field having null values

This commit is contained in:
Benjamin Eberlei 2010-09-13 21:48:25 +02:00
parent ee9158ffb4
commit da63bad9c8
2 changed files with 19 additions and 2 deletions

View File

@ -1881,7 +1881,7 @@ class UnitOfWork implements PropertyChangedListener
if ($assoc['isOwningSide']) {
$associatedId = array();
foreach ($assoc['targetToSourceKeyColumns'] as $targetColumn => $srcColumn) {
$joinColumnValue = $data[$srcColumn];
$joinColumnValue = isset($data[$srcColumn]) ? $data[$srcColumn] : null;
if ($joinColumnValue !== null) {
$associatedId[$targetClass->fieldNames[$targetColumn]] = $joinColumnValue;
}

View File

@ -65,6 +65,23 @@ class DDC522Test extends \Doctrine\Tests\OrmFunctionalTestCase
$this->assertTrue($fkt2->cart instanceof \Doctrine\ORM\Proxy\Proxy);
$this->assertFalse($fkt2->cart->__isInitialized__);
}
/**
* @group DDC-522
* @group DDC-762
*/
public function testJoinColumnWithNullSameNameAssociationField()
{
$fkCust = new DDC522ForeignKeyTest;
$fkCust->name = "name";
$fkCust->cart = null;
$this->_em->persist($fkCust);
$this->_em->flush();
$this->_em->clear();
$newCust = $this->_em->find(get_class($fkCust), $fkCust->id);
}
}
/** @Entity */
@ -94,7 +111,7 @@ class DDC522Cart {
class DDC522ForeignKeyTest {
/** @Id @Column(type="integer") @GeneratedValue */
public $id;
/** @Column(type="integer", name="cart_id") */
/** @Column(type="integer", name="cart_id", nullable="true") */
public $cartId;
/**
* @OneToOne(targetEntity="DDC522Cart")