mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
UniqueIndex attribute on entity can cause some packaged CLI tools to error #7316
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 @Firehed on GitHub (Feb 11, 2024).
Bug Report
Summary
If a table has a UniqueConstraint attribute where there's no name neing explicitly set (e.g.
#[Mapping\UniqueConstraint(fields: ['email'])]), several included CLI tools produce an error:I also tested by replacing the
UniqueConstraintwith anIndexand that has the correct behavior. It appears isolated to unique indexes.Current behavior
Instead of a deterministic index name being generated from the referenced values, the above error is produced.
How to reproduce
UniqueConstraintattribute. Bothfieldsandcolumnsdefinitions reproduce this. Do not explicitly set aname.orm:infoorm:validateorm:schema-tool:update --dump-sqlExpected behavior
If
nameis specified in the attribute, it's used (this IS the current behavior). If not, one is generated based on the columns as occurred in ORM 2.x.@BenMorel commented on GitHub (Feb 28, 2024):
We have the same issue, and indeed, adding a
nameto eachUniqueConstraintfixes it.We're using version
3.0.1.