#35103 closed Cleanup/optimization (fixed)
UniqueConstraint message does not use violation_error_message
| Reported by: | Gerben Morsink | Owned by: | Gerben Morsink |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | 5.1 |
| Severity: | Normal | Keywords: | UniqueConstraint, violation_error_message |
| Cc: | Simon Charette | Triage Stage: | Ready for checkin |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Although this is documented, it is unexpected. Therefore I filed it as a cleanup/optimization.
See https://forum.djangoproject.com/t/customizing-validationerror-message-on-uniqueconstraint/25105 for a (possible) patch.
Change History (20)
comment:1 by , 22 months ago
| Has patch: | unset |
|---|---|
| Triage Stage: | Unreviewed → Accepted |
| UI/UX: | unset |
comment:2 by , 22 months ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
comment:4 by , 22 months ago
| Has patch: | set |
|---|
comment:5 by , 22 months ago
| Needs documentation: | set |
|---|
comment:6 by , 18 months ago
| Needs documentation: | unset |
|---|
comment:7 by , 18 months ago
| Patch needs improvement: | set |
|---|
comment:8 by , 18 months ago
| Patch needs improvement: | unset |
|---|---|
| Version: | 4.1 → dev |
comment:9 by , 17 months ago
| Version: | dev → 5.1 |
|---|
comment:10 by , 17 months ago
| Patch needs improvement: | set |
|---|
comment:11 by , 17 months ago
| Patch needs improvement: | unset |
|---|
comment:12 by , 17 months ago
| Needs tests: | set |
|---|---|
| Patch needs improvement: | set |
comment:13 by , 17 months ago
| Patch needs improvement: | unset |
|---|
comment:14 by , 14 months ago
| Needs tests: | unset |
|---|---|
| Resolution: | → fixed |
| Status: | assigned → closed |
comment:15 by , 14 months ago
| Resolution: | fixed |
|---|---|
| Status: | closed → new |
Please do not close a ticket before its patch is committed in the repository. Unsetting the "Needs tests" flag should be enough to promote the patch in the review queue again!
comment:16 by , 14 months ago
| Easy pickings: | unset |
|---|---|
| Patch needs improvement: | set |
comment:17 by , 14 months ago
Somehow a lot of seemingly unrelated tests are failing on my local machine. It could have to do with https://code.djangoproject.com/ticket/30581 being merged in between the first release and the current release.
@Sarah Boyce: do you know why these lines were changed:
https://github.com/django/django/commit/13922580cccfb9ab2922ff4943dd39da56dfbd8c ?
comment:18 by , 13 months ago
| Patch needs improvement: | unset |
|---|---|
| Triage Stage: | Accepted → Ready for checkin |
comment:20 by , 2 months ago
I think this is still perhaps not working as intended, in particular when using expressions. We can see with the simple case:
from django.db import models
class MyModel(models.Model)
name = models.CharField()
class Meta:
constraints = (
models.UniqueConstraint(
Lower("name"),
name="unique_supplier_name",
violation_error_message="test"
),
)
If for some reason it should be obvious and expected that violation_error_message should not apply when using expressions, I think we could perhaps clean up the docs to clarify this (and maybe why).
While Simon did provide a draft patch on the forum, I'll uncheck "Has patch" until there is a pull request to review.