[DDC-3027] Avoid duplicated mapping using Embedded in MappedSuperclass
This commit is contained in:
parent
7a305475e3
commit
8a3def097f
@ -141,13 +141,17 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory
|
||||
$this->completeIdGeneratorMapping($class);
|
||||
}
|
||||
|
||||
foreach ($class->embeddedClasses as $property => $embeddableClass) {
|
||||
if (isset($embeddableClass['inherited'])) {
|
||||
continue;
|
||||
}
|
||||
if (!$class->isMappedSuperclass) {
|
||||
|
||||
$embeddableMetadata = $this->getMetadataFor($embeddableClass['class']);
|
||||
$class->inlineEmbeddable($property, $embeddableMetadata);
|
||||
foreach ($class->embeddedClasses as $property => $embeddableClass) {
|
||||
|
||||
if (isset($embeddableClass['inherited'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$embeddableMetadata = $this->getMetadataFor($embeddableClass['class']);
|
||||
$class->inlineEmbeddable($property, $embeddableMetadata);
|
||||
}
|
||||
}
|
||||
|
||||
if ($parent && $parent->isInheritanceTypeSingleTable()) {
|
||||
|
@ -17,6 +17,8 @@ class ValueObjectsTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC93Address'),
|
||||
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC93Vehicle'),
|
||||
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC93Car'),
|
||||
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC3027Animal'),
|
||||
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC3027Dog'),
|
||||
));
|
||||
} catch(\Exception $e) {
|
||||
}
|
||||
@ -212,6 +214,15 @@ class ValueObjectsTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
|
||||
$this->assertEquals($expectedColumnName, $actualColumnName);
|
||||
}
|
||||
|
||||
public function testInlineEmbeddableInMappedSuperClass()
|
||||
{
|
||||
$isFieldMapped = $this->_em
|
||||
->getClassMetadata(__NAMESPACE__ . '\DDC3027Dog')
|
||||
->hasField('address.street');
|
||||
|
||||
$this->assertTrue($isFieldMapped);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -396,3 +407,22 @@ class DDC3028Id
|
||||
$this->id = $id;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @MappedSuperclass
|
||||
*/
|
||||
abstract class DDC3027Animal
|
||||
{
|
||||
/** @Id @GeneratedValue(strategy = "AUTO") @Column(type = "integer") */
|
||||
public $id;
|
||||
|
||||
/** @Embedded(class = "DDC93Address") */
|
||||
public $address;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
*/
|
||||
class DDC3027Dog extends DDC3027Animal
|
||||
{
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user