Skip to content

Commit 80a9a3c

Browse files
Inherit sequence generator definitions from mapped superclasses
1 parent 03783f8 commit 80a9a3c

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

src/Mapping/ClassMetadataFactory.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,11 @@ protected function doLoadMetadata(
138138
$class->setInheritanceType($parent->inheritanceType);
139139
$class->setDiscriminatorColumn($parent->discriminatorColumn === null ? null : clone $parent->discriminatorColumn);
140140
$class->setIdGeneratorType($parent->generatorType);
141+
142+
if ($parent->isIdGeneratorSequence()) {
143+
$class->setSequenceGeneratorDefinition($parent->sequenceGeneratorDefinition);
144+
}
145+
141146
$this->addInheritedFields($class, $parent);
142147
$this->addInheritedRelations($class, $parent);
143148
$this->addInheritedEmbeddedClasses($class, $parent);

tests/Tests/ORM/Mapping/BasicInheritanceMappingTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,19 @@ public function testMappedSuperclassWithId(): void
157157
self::assertArrayHasKey('id', $class->fieldMappings);
158158
}
159159

160+
#[Group('GH-12390')]
161+
public function testSequenceDefinitionFromMappedSuperclassIsInherited(): void
162+
{
163+
$class = $this->cmf->getMetadataFor(SuperclassEntity::class);
164+
assert($class instanceof ClassMetadata);
165+
166+
self::assertInstanceOf(IdSequenceGenerator::class, $class->idGenerator);
167+
self::assertSame(
168+
['sequenceName' => 'foo', 'allocationSize' => '1', 'initialValue' => '10'],
169+
$class->sequenceGeneratorDefinition,
170+
);
171+
}
172+
160173
#[Group('DDC-1156')]
161174
#[Group('DDC-1218')]
162175
#[Group('GH-10927')]

0 commit comments

Comments
 (0)