[Django] #28111: Allow skipping validations done in database for Model.full_clean()

4 views
Skip to first unread message

Django

unread,
Apr 21, 2017, 2:10:06 AM4/21/17
to django-...@googlegroups.com
#28111: Allow skipping validations done in database for Model.full_clean()
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
holvianssi |
Type: New | Status: new
feature |
Component: Database | Version: master
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
A common practice for Model.save() is to do something like:
{{{
def save():
self.full_clean()
super().save()
}}}
The idea is to validate for example field.choices, and other things that
aren't checked in database. Unfortunately this also checks unique
constraints, foreign keys etc, which is non-necessary in the common case -
the checks would be ran in the database in any case, and the db is much
faster in checking these constraints.

It would be nice that we could instead do something like this:
{{{
def save():
self.full_clean(skip_checks_done_in_database=True)
super().save()
}}}
This way we would have the additional safety of checking choices and other
things that aren't checked in the database, but we wouldn't have overhead
of checking a lot of constraints that are already checked in the database.

--
Ticket URL: <https://code.djangoproject.com/ticket/28111>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 15, 2017, 12:17:44 PM5/15/17
to django-...@googlegroups.com
#28111: Allow skipping validations done in database for Model.full_clean()
-------------------------------------+-------------------------------------
Reporter: holvianssi | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham):

I'm not sure how feasible this would be to implement. It seems like that
flag would have to be passed all the way to `Field.clean()` and to the
field's validators. It's difficult to know which validators are duplicated
and which aren't, especially as behavior might vary across databases. Were
you thinking of offering a patch?

--
Ticket URL: <https://code.djangoproject.com/ticket/28111#comment:1>

Django

unread,
May 26, 2017, 8:01:42 AM5/26/17
to django-...@googlegroups.com
#28111: Allow skipping validations done in database for Model.full_clean()
-------------------------------------+-------------------------------------
Reporter: holvianssi | Owner: nobody
Type: New feature | Status: closed

Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* status: new => closed
* resolution: => needsinfo


--
Ticket URL: <https://code.djangoproject.com/ticket/28111#comment:2>

Reply all
Reply to author
Forward
0 new messages