Description
Bug Report
Q | A |
---|---|
BC Break | no |
Version | >=2.9.x |
Summary
Since the implementation of the AttributeDriver
there's a bug that the properties of the Table
attribute aren't counted in for the indices and unique constraints.
Current behavior
Currently setting the indices and unique constraints through the Table
attribute results in them being ignored which therefore disallows the usage of nested attributes.
This is being handled here:
orm/src/Mapping/Driver/AttributeDriver.php
Lines 165 to 173 in a809a71
Before with annotations, this was possible and the code for the correct interpretation of these was implemented in the AnnotationDriver
:
orm/src/Mapping/Driver/AnnotationDriver.php
Lines 137 to 224 in a809a71
How to reproduce
Creating an entity with the following attributes:
#[Orm\Entity()]
#[Orm\Table(
'some_entities',
indexes: [
new Orm\Index(['some_column_1'], name: 'some_name_1'),
new Orm\Index(['some_column_2'], name: 'some_name_2'),
],
uniqueConstraints: [
new Orm\UniqueConstraint('some_unique_constraint', ['some_column_3']),
],
)]
class SomeEntity
{
// [...]
}
This wouldn't be handled by the AttributeDriver
.
But doing it this way works:
#[Orm\Entity()]
#[Orm\Table('some_entities')]
#[Orm\Index(['some_column_1'], name: 'some_name_1')]
#[Orm\Index(['some_column_2'], name: 'some_name_2')]
#[Orm\UniqueConstraint('some_unique_constraint', ['some_column_3'])]
class SomeEntity
{
// [...]
}
Expected behavior
The nested attribute variant should also work as expected if indices and / or unique constrains are defined within the Table
attribute.
OR if this is unwanted behavior it should be removed to reduce confusions in terms of defining the table definitions.