mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Doctrine ignores Index and just takes UniqueConstraint into account for the same field #5894
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 @bentcoder on GitHub (Feb 20, 2018).
Originally assigned to: @Ocramius on GitHub.
Hi,
I am not sure if this is a bug or an expected behaviour of Doctrine.
If I set
UniqueConstraintandIndexon a same field, Doctrine ignores creating aIndexentry in database. However, if I removeUniqueConstraint, Doctrine createsIndexentry in database. Seems like we cannot set bothUniqueConstraintandIndexon a same field with Doctrine. Doctrine prefersUniqueConstraintoverIndexif they both set on a same field.Note: At database level, we can manually set UNQ and IDX on same field.
Thanks
MAPPING 1
DQL 1
MAPPING 2
DQL 2
@Ocramius commented on GitHub (Feb 20, 2018):
This is expected behavior.
Ref: https://github.com/doctrine/dbal/pull/769
Ref: https://github.com/doctrine/dbal/pull/764
Can't find the original issue where we actually decided to de-duplicate overlapping/redundant indexes.
@bentcoder commented on GitHub (Feb 20, 2018):
I've went through those links but there is nothing clear there as there are too many references all over the place.
As far as I can see this is how Doctrine intend to work.