#34319: Model.validate_constraints() crashes when constraint's validate() raises
ValidationError without a code.
-------------------------------------+-------------------------------------
Reporter: Mateusz Kurowski | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 4.1
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: Model, | Triage Stage: Accepted
validate_constraints, |
ValidationError, code, message |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):
* cc: Gagaro (added)
* type: Cleanup/optimization => Bug
* severity: Normal => Release blocker
* stage: Unreviewed => Accepted
Comment:
Replying to [ticket:34319 Mateusz Kurowski]:
> This wont work because:
>
> {{{
> 1425, in validate_constraints
> if e.code == "unique" and len(constraint.fields) == 1:
> ^^^^^^
> AttributeError: 'ValidationError' object has no attribute 'code'
> }}}
This is a regression in 667105877e6723c6985399803a364848891513cc, that we
should fix.
> Maybe all unique constraints should allow raising validation error for
specific field like ?
I don't think that adding extra arguments is a step forward here, we
should be able to recognized violated fields by inspecting `expression`,
see #34007.
--
Ticket URL: <https://code.djangoproject.com/ticket/34319#comment:5>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/010701862fc15d8a-510316ae-fc47-4953-8f61-1b88ce988636-000000%40eu-central-1.amazonses.com.