#28405: CICharField on a ModelFormSet doesn't catch unique constraint violations
with different capitalization
----------------------------------+------------------------------------
     Reporter:  Jon Dufresne      |                    Owner:  (none)
         Type:  Bug               |                   Status:  new
    Component:  contrib.postgres  |                  Version:  1.11
     Severity:  Normal            |               Resolution:
     Keywords:                    |             Triage Stage:  Accepted
    Has patch:  0                 |      Needs documentation:  0
  Needs tests:  0                 |  Patch needs improvement:  0
Easy pickings:  0                 |                    UI/UX:  0
----------------------------------+------------------------------------

Comment (by Jon Dufresne):

 As a potential solution, what do others think about catching the
 database's `IntegrityError` during `ModelForm.save()` to report unique
 constraint violations in model forms? The database is already optimized
 for robust checking of unique constraints, why repeat that code at the
 application layer? It produces subtle differences and edge cases. This
 solution could potentially deprecate the large amounts of Django code used
 to check if a submitted form violates unique constraints and rely on the
 basic database feature instead. All builtin datbase backends support
 unique constraints. If we rely on the database, we wouldn't need to figure
 out how the database is comparing rows (case sensitive vs case
 insensitive), it'll tell us.

 Something to note, this would mean that not all validation occurs before
 the `ModelForm.save()` and that the `ModelForm.save()` can be unsuccessful
 and could add errors to the form.

 (Usual backward compatibility concerns apply.)

-- 
Ticket URL: <https://code.djangoproject.com/ticket/28405#comment:2>
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.eda45d17643d4c2ed0d45a45ddc4c8e6%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to