mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
AttributeDriver ignores index and unique constraint definitions in Table attribute
#7341
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @DaDeather on GitHub (Mar 13, 2024).
Bug Report
Summary
Since the implementation of the
AttributeDriverthere's a bug that the properties of theTableattribute aren't counted in for the indices and unique constraints.Current behavior
Currently setting the indices and unique constraints through the
Tableattribute results in them being ignored which therefore disallows the usage of nested attributes.This is being handled here:
a809a71aa6/src/Mapping/Driver/AttributeDriver.php (L165-L173)Before with annotations, this was possible and the code for the correct interpretation of these was implemented in the
AnnotationDriver:a809a71aa6/src/Mapping/Driver/AnnotationDriver.php (L137-L224)How to reproduce
Creating an entity with the following attributes:
This wouldn't be handled by the
AttributeDriver.But doing it this way works:
Expected behavior
The nested attribute variant should also work as expected if indices and / or unique constrains are defined within the
Tableattribute.OR if this is unwanted behavior it should be removed to reduce confusions in terms of defining the table definitions.
@DaDeather commented on GitHub (Mar 13, 2024):
Relates to:
PR - https://github.com/doctrine/orm/pull/9241
Issue - https://github.com/doctrine/orm/issues/9240
@derrabus commented on GitHub (Mar 13, 2024):
We should remove those properties
indexesanduniqueConstraintsindeed as they don't have a function anymore. We should not provide two ways of achieving the same thing. Do you want to work on a PR?@DaDeather commented on GitHub (Mar 13, 2024):
As we both agree on it being unnecessary to have 2 different approaches to the same, I've created a PR to remove these properties from the
Tableattribute instead to reduce unnecessary complexity and confusion 👍.