diff --git a/classification/models/condition_text_matching.py b/classification/models/condition_text_matching.py index 1ab7ed947..80419c2f1 100644 --- a/classification/models/condition_text_matching.py +++ b/classification/models/condition_text_matching.py @@ -338,8 +338,8 @@ def sync_condition_text_classification(cm: ClassificationModification, update_co ct: ConditionText ct, ct_is_new = ConditionText.objects.get_or_create(normalized_text=normalized, lab=lab) - ct = ConditionText.objects.select_for_update().filter(pk=ct.pk).first() with transaction.atomic(): + ct = ConditionText.objects.select_for_update().filter(pk=ct.pk).first() # ensure each step of the hierarchy is present root, new_root = ConditionTextMatch.objects.get_or_create(