Skip to content

Fix unique validators on CreateClassification

Erwan Rouchet requested to merge fix-classification-unique-validators into master

Closes #761 (closed)

This bug could also occur when creating two classifications with two different worker run IDs but on the same worker version.

I added a new ConditionalUniqueValidator class, which we will be able to reuse in other serializers to validate partial unique constraints. Those constraints are currently poorly supported by both Django and DRF, despite Django clearly moving away from Meta.unique_together and towards Meta.constraints, and we are using them more and more, especially for worker runs.

The manual classification validator is only used when creating a new manual classification, the worker version valdiator is only used when creating a new classification with a worker version and no worker run, and the worker run validator is only used when creating a new classification with a worker run.

This removes 1 or 2 queries on most calls to CreateClassification.

Merge request reports

Loading