mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Is it possible to detect exactly which database constraint was violated during exception handling? #5467
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 @BabakMN on GitHub (Mar 17, 2017).
Originally assigned to: @Ocramius on GitHub.
I'd like to know if it's possible to detect which constraint was violated during a constraint violation exception?
Or alternatively, which column(s) was involved.
The use case is for when multiple unique constraints are placed on a table and then an insert fails because of a violation.
For complete error handling you would need to know exactly which constraint was involved in the violation.
This can be done by doing a string search on the text of the error message however I'm wondering if a better solution is available.
@Ocramius commented on GitHub (Mar 17, 2017):
The error message already provides this information: this is not something
that the ORM should do, but rather your rdbms.
On 17 Mar 2017 1:50 a.m., "BabakMN" notifications@github.com wrote: