Skip to content

Commit

Permalink
DDC-1515 - Merge from 2.1.x
Browse files Browse the repository at this point in the history
  • Loading branch information
beberlei committed Dec 11, 2011
1 parent 954b507 commit bd0fb57
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php
Expand Up @@ -244,6 +244,7 @@ protected function gatherRowData(array $data, array &$cache, array &$id, array &

if (isset($cache[$key]['isMetaColumn'])) {
if ( ! isset($rowData[$dqlAlias][$cache[$key]['fieldName']]) || $value !== null) {
$nonemptyComponents[$dqlAlias] = true;
$rowData[$dqlAlias][$cache[$key]['fieldName']] = $value;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php
Expand Up @@ -332,9 +332,9 @@ protected function hydrateRowData(array $row, array &$cache, array &$result)
// Hydrate the data chunks
foreach ($rowData as $dqlAlias => $data) {
$entityName = $this->_rsm->aliasMap[$dqlAlias];

if (isset($this->_rsm->parentAliasMap[$dqlAlias])) {
// It's a joined result
// It's a joined result

$parentAlias = $this->_rsm->parentAliasMap[$dqlAlias];
// we need the $path to save into the identifier map which entities were already
Expand Down
64 changes: 64 additions & 0 deletions tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1515Test.php
@@ -0,0 +1,64 @@
<?php

namespace Doctrine\Tests\ORM\Functional\Ticket;


/**
* @group DDC-1515
*/
class DDC1515Test extends \Doctrine\Tests\OrmFunctionalTestCase
{
public function setUp()
{
parent::setUp();
$this->_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;
}


0 comments on commit bd0fb57

Please sign in to comment.