1
0
mirror of synced 2025-01-08 10:07:10 +03:00

DDC-1632 Optimized query count for one-to-many associations with fetch eager.

This commit is contained in:
Guilherme Blanco 2014-04-16 05:36:31 +00:00
parent 4029dc2ea8
commit b28fa9a05a
2 changed files with 6 additions and 3 deletions

View File

@ -1159,7 +1159,10 @@ class BasicEntityPersister implements EntityPersister
$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;
}

View File

@ -38,11 +38,11 @@ class DDC2350Test extends OrmFunctionalTestCase
$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());
}
}