Skip to content

Commit

Permalink
DDC-1632 Optimized query count for one-to-many associations with fetc…
Browse files Browse the repository at this point in the history
…h eager.
  • Loading branch information
guilhermeblanco committed Apr 16, 2014
1 parent 4029dc2 commit b28fa9a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion lib/Doctrine/ORM/Persisters/BasicEntityPersister.php
Expand Up @@ -1159,7 +1159,10 @@ protected function getSelectColumnsSQL()
$columnList[] = $assocColumnSQL;
}

if ( ! (($assoc['type'] & ClassMetadata::TO_ONE) && ($assoc['fetch'] == ClassMetadata::FETCH_EAGER || !$assoc['isOwningSide']))) {
$isAssocToOneInverseSide = $assoc['type'] & ClassMetadata::TO_ONE && ! $assoc['isOwningSide'];
$isAssocFromOneEager = $assoc['type'] !== ClassMetadata::MANY_TO_MANY && $assoc['fetch'] === ClassMetadata::FETCH_EAGER;

if ( ! ($isAssocFromOneEager || $isAssocToOneInverseSide)) {
continue;
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2350Test.php
Expand Up @@ -38,11 +38,11 @@ public function testEagerCollectionsAreOnlyRetrievedOnce()
$cnt = $this->getCurrentQueryCount();
$user = $this->_em->find(__NAMESPACE__ . '\DDC2350User', $user->id);

$this->assertEquals($cnt + 2, $this->getCurrentQueryCount());
$this->assertEquals($cnt + 1, $this->getCurrentQueryCount());

$this->assertEquals(2, count($user->reportedBugs));

$this->assertEquals($cnt + 2, $this->getCurrentQueryCount());
$this->assertEquals($cnt + 1, $this->getCurrentQueryCount());
}
}

Expand Down

0 comments on commit b28fa9a

Please sign in to comment.