#34296: Formset validation does not consider UniqueConstraint with F() 
expressions.
-------------------------------------+-------------------------------------
     Reporter:  Jannis Vajen         |                    Owner:  nobody
         Type:  Bug                  |                   Status:  closed
    Component:  Database layer       |                  Version:  dev
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  duplicate
     Keywords:  formset,             |             Triage Stage:  Accepted
  constraints                        |
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Jannis Vajen):

 Thank you, Mariusz. Using `fields=[]` works as expected.

 If `UniqueConstraints` with `expressions` are excluded from validation on
 purpose, I wonder if this should be mentioned in the docs. It seems to me
 that the admonition you added in #33335

 > **Validation of Constraints**
 >
 > In general constraints are not checked during full_clean(), and do not
 raise ValidationErrors. Rather you’ll get a database integrity error on
 save(). UniqueConstraints without a condition (i.e. non-partial unique
 constraints) and expressions (i.e. non-functional unique constraints) are
 different in this regard, in that they leverage the existing
 validate_unique() logic, and thus enable two-stage validation. In addition
 to IntegrityError on save(), ValidationError is also raised during model
 validation when the UniqueConstraint is violated.

 still fully applies in 4.1, 4.2, and dev and should not have been removed
 during #30581

 > **Validation of Constraints**
 >
 > Constraints are checked during the model validation.

 Do you agree, or am I overlooking something?

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34296#comment:4>
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/01070185f314d471-5448d581-a722-4a49-8040-14ddaf573442-000000%40eu-central-1.amazonses.com.

Reply via email to