Opened 5 years ago
Closed 5 years ago
#30910 closed New feature (wontfix)
Add system check warning on duplicate check constraints.
Reported by: | Jon Dufresne | Owned by: | nobody |
---|---|---|---|
Component: | Core (System checks) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Recently, due to an oversight when copying & pasting code, I created a duplicate CheckConstraint
. I had intended to modify the check
argument after pasting, but I made a mistake. In this specific instance, the mistake was caught and fixed during a routine code review, but it made me think this is something that could be warned against by Django so it is caught early.
While a duplicate check constraint is legal SQL, it normally points to an error on the part of the developer. We can issue a Warning
in such a case.
Change History (3)
comment:1 by , 5 years ago
Has patch: | set |
---|
comment:3 by , 5 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
Reviewing again with Mariusz, we're not convinced the proposed solution is sufficiently robust to capture more than the most naive cases. (There are just too many ways of writing equivalent constraints.) As such, we're not convinced of the value of the check. (Leaning towards a suspicion it would actually be unhelpful on balance, which we've seen with other proposed system checks at times.) Will close on that basis.
Possible to revisit if a way of reducing semantically equivalent constraints turns up...
(c.f. [https://github.com/django/django/pull/11973 Discussion on PR].)
https://github.com/django/django/pull/11973