DDC-762 - Fixed notice when mapping foreign keys to field having null values
This commit is contained in:
parent
ee9158ffb4
commit
da63bad9c8
@ -1881,7 +1881,7 @@ class UnitOfWork implements PropertyChangedListener
|
|||||||
if ($assoc['isOwningSide']) {
|
if ($assoc['isOwningSide']) {
|
||||||
$associatedId = array();
|
$associatedId = array();
|
||||||
foreach ($assoc['targetToSourceKeyColumns'] as $targetColumn => $srcColumn) {
|
foreach ($assoc['targetToSourceKeyColumns'] as $targetColumn => $srcColumn) {
|
||||||
$joinColumnValue = $data[$srcColumn];
|
$joinColumnValue = isset($data[$srcColumn]) ? $data[$srcColumn] : null;
|
||||||
if ($joinColumnValue !== null) {
|
if ($joinColumnValue !== null) {
|
||||||
$associatedId[$targetClass->fieldNames[$targetColumn]] = $joinColumnValue;
|
$associatedId[$targetClass->fieldNames[$targetColumn]] = $joinColumnValue;
|
||||||
}
|
}
|
||||||
|
@ -65,6 +65,23 @@ class DDC522Test extends \Doctrine\Tests\OrmFunctionalTestCase
|
|||||||
$this->assertTrue($fkt2->cart instanceof \Doctrine\ORM\Proxy\Proxy);
|
$this->assertTrue($fkt2->cart instanceof \Doctrine\ORM\Proxy\Proxy);
|
||||||
$this->assertFalse($fkt2->cart->__isInitialized__);
|
$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 */
|
/** @Entity */
|
||||||
@ -94,7 +111,7 @@ class DDC522Cart {
|
|||||||
class DDC522ForeignKeyTest {
|
class DDC522ForeignKeyTest {
|
||||||
/** @Id @Column(type="integer") @GeneratedValue */
|
/** @Id @Column(type="integer") @GeneratedValue */
|
||||||
public $id;
|
public $id;
|
||||||
/** @Column(type="integer", name="cart_id") */
|
/** @Column(type="integer", name="cart_id", nullable="true") */
|
||||||
public $cartId;
|
public $cartId;
|
||||||
/**
|
/**
|
||||||
* @OneToOne(targetEntity="DDC522Cart")
|
* @OneToOne(targetEntity="DDC522Cart")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user