Skip to content
Snippets Groups Projects
Commit 140f59be authored by Valentin Rigal's avatar Valentin Rigal Committed by Erwan Rouchet
Browse files

Suggestions

parent f722a61f
No related branches found
No related tags found
1 merge request!2276Dataset unique elements
This commit is part of merge request !2276. Comments created here will be created in the context of that merge request.
......@@ -11,9 +11,9 @@ def update_unique_elements(apps, schema_editor):
models.Exists(
DatasetElement.objects
.filter(set__dataset_id=models.OuterRef("pk"))
.values("element")
.annotate(dups=models.Count("element"))
.filter(dups__gte=2)
.values("element_id")
.annotate(dupes=models.Count("element_id"))
.filter(dupes__gte=2)
)
).update(unique_elements=False)
......
......@@ -583,9 +583,9 @@ class DatasetSerializer(serializers.ModelSerializer):
if unique is True and self.instance and (
DatasetElement.objects
.filter(set__dataset_id=self.instance.pk)
.values("element")
.annotate(dups=Count("element"))
.filter(dups__gte=2)
.values("element_id")
.annotate(dupes=Count("element_id"))
.filter(dupes__gte=2)
.exists()
):
raise ValidationError("Elements are currently contained by multiple sets.")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment