Opened 4 weeks ago
Last modified 3 weeks ago
#37329 assigned New feature
Allow customizing ValidationError code in UniqueConstraint
| Reported by: | Tim Schilling | Owned by: | Md. Saikat Islam |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | yes | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
This is based on @xafer's PR. It was a follow-up to #34338.
Since violation_error_code could never be defined for UniqueConstraint prior to #16560 there is no backward compatibility to bother with.
But if the user bothered to provide a violation_error_code to its UniqueConstraint it is likely expecting it to be used.
I think it makes sense given that we now allow more customization of these constraints to allow customizing the violation_error_code as well.
Change History (6)
comment:1 by , 4 weeks ago
| Summary: | Allowed customizing ValidationError code in UniqueConstraint → Allow customizing ValidationError code in UniqueConstraint |
|---|
comment:2 by , 4 weeks ago
| Owner: | set to |
|---|---|
| Status: | new → assigned |
| Triage Stage: | Unreviewed → Accepted |
comment:4 by , 3 weeks ago
| Type: | Uncategorized → New feature |
|---|
comment:5 by , 3 weeks ago
| Has patch: | set |
|---|---|
| Needs tests: | set |
comment:6 by , 3 weeks ago
Please review the PR for this ticket: https://github.com/django/django/pull/21933
After inspecting the codebase,
CheckConstraintandExclusionConstraintalready fully support customizingviolation_error_code. SoUniqueConstraintshould allow customizing ValidationError Code.