1
0
mirror of synced 2025-01-18 22:41:43 +03:00

[DDC-2423] Fixed bug with EntityGenerator not generating fetch="" attribute in association annotations.

This commit is contained in:
Benjamin Eberlei 2013-05-09 10:55:12 +02:00
parent acbafd081b
commit e3b8ce7737
2 changed files with 12 additions and 0 deletions

View File

@ -1274,6 +1274,15 @@ public function __construct()
$typeOptions[] = 'orphanRemoval=' . ($associationMapping['orphanRemoval'] ? 'true' : 'false');
}
if (isset($associationMapping['fetch']) && $associationMapping['fetch'] !== ClassMetadataInfo::FETCH_LAZY) {
$fetchMap = array(
ClassMetadataInfo::FETCH_EXTRA_LAZY => 'EXTRA_LAZY',
ClassMetadataInfo::FETCH_EAGER => 'EAGER',
);
$typeOptions[] = 'fetch="' . $fetchMap[$associationMapping['fetch']] . '"';
}
$lines[] = $this->spaces . ' * @' . $this->annotationsPrefix . '' . $type . '(' . implode(', ', $typeOptions) . ')';
if (isset($associationMapping['joinColumns']) && $associationMapping['joinColumns']) {

View File

@ -64,6 +64,7 @@ class EntityGeneratorTest extends \Doctrine\Tests\OrmTestCase
$metadata->mapManyToMany(array(
'fieldName' => 'comments',
'targetEntity' => 'Doctrine\Tests\ORM\Tools\EntityGeneratorComment',
'fetch' => ClassMetadataInfo::FETCH_EXTRA_LAZY,
'joinTable' => array(
'name' => 'book_comment',
'joinColumns' => array(array('name' => 'book_id', 'referencedColumnName' => 'id')),
@ -223,6 +224,8 @@ class EntityGeneratorTest extends \Doctrine\Tests\OrmTestCase
$this->assertEquals($cm->identifier, $metadata->identifier);
$this->assertEquals($cm->idGenerator, $metadata->idGenerator);
$this->assertEquals($cm->customRepositoryClassName, $metadata->customRepositoryClassName);
$this->assertEquals(ClassMetadataInfo::FETCH_EXTRA_LAZY, $cm->associationMappings['comments']['fetch']);
}
public function testLoadPrefixedMetadata()