Skip to content

Assume/require django_full_clean? Build our own? #128

@sjamaan

Description

@sjamaan

In one project, I've noticed that we do quite a lot of validations, to the point where a simple PUT incurs about 40 queries. I've managed to bring it down to about two thirds of that by overriding binder_full_clean to do nothing.

As far as I know, we're using django-full-clean in all our projects, so that whenever you call save(), full_clean gets triggered anyway. Maybe it's time to make it official and require it in Binder. Then we can drop most of binder_full_clean.

I've also noticed that full_clean doesn't support selectively disabling constraint validations. I think that if we see that a model includes the LoadedValuesMixin, we can check if any relations have changed. If not, we can in principle assume that all the foreign key constraint validations will succeed and pass all unchanged relations as exclude. If none of the uniqueness fields have changed, we can also pass in validate_unique=False. Now, there can be race conditions, but I think because we're using select_for_update that isn't or can't really be the case.

If we want to leverage LoadedValuesMixin, I think we must build our own django_full_clean replacement as part of Binder. This is not a big deal, as the implementation is just a handful of lines anyway.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions