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 Tim Schilling, 4 weeks ago

Summary: Allowed customizing ValidationError code in UniqueConstraint → Allow customizing ValidationError code in UniqueConstraint

comment:2 by Md. Saikat Islam, 4 weeks ago

Owner: set to Md. Saikat Islam
Status: new → assigned
Triage Stage: Unreviewed → Accepted

After inspecting the codebase, CheckConstraint and ExclusionConstraint already fully support customizing violation_error_code. So UniqueConstraint should allow customizing ValidationError Code.

comment:3 by Md. Saikat Islam, 3 weeks ago

Should this ticket category be updated to New Feature?

comment:4 by Md. Saikat Islam, 3 weeks ago

Type: Uncategorized → New feature

comment:5 by Md. Saikat Islam, 3 weeks ago

Has patch: set
Needs tests: set

comment:6 by Md. Saikat Islam, 3 weeks ago

Please review the PR for this ticket: ​https://github.com/django/django/pull/21933

Note: See TracTickets for help on using tickets.
Back to Top