From 40d094fea218555429a2c0a7b01216c8f62149c3 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Sun, 11 Dec 2011 17:08:58 +0100 Subject: [PATCH] DDC-1515 - Now the real bugfix --- .../Internal/Hydration/AbstractHydrator.php | 3 + .../ORM/Functional/Ticket/DDC1515Test.php | 64 +++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1515Test.php diff --git a/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php index 146dfb5c5..6c095c9e3 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php @@ -245,6 +245,9 @@ abstract class AbstractHydrator if (isset($cache[$key]['isMetaColumn'])) { if ( ! isset($rowData[$dqlAlias][$cache[$key]['fieldName']]) || $value !== null) { $rowData[$dqlAlias][$cache[$key]['fieldName']] = $value; + if ($cache[$key]['isIdentifier']) { + $nonemptyComponents[$dqlAlias] = true; + } } continue; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1515Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1515Test.php new file mode 100644 index 000000000..9bd3360b8 --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1515Test.php @@ -0,0 +1,64 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1515Foo'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1515Bar'), + )); + } + + public function testIssue() + { + $bar = new DDC1515Bar(); + $this->_em->persist($bar); + $this->_em->flush(); + + $foo = new DDC1515Foo(); + $foo->bar = $bar; + $this->_em->persist($foo); + $this->_em->flush(); + $this->_em->clear(); + + $bar = $this->_em->find(__NAMESPACE__ . '\DDC1515Bar', $bar->id); + $this->assertInstanceOf(__NAMESPACE__.'\DDC1515Foo', $bar->foo); + } +} + +/** + * @Entity + */ +class DDC1515Foo +{ + /** + * @OneToOne(targetEntity="DDC1515Bar", inversedBy="foo") @Id + */ + public $bar; +} + +/** + * @Entity + */ +class DDC1515Bar +{ + /** + * @Id @Column(type="integer") @GeneratedValue + */ + public $id; + + /** + * @OneToOne(targetEntity="DDC1515Foo", mappedBy="bar") + */ + public $foo; +} + +