From b6103d9b6008a164dd9f38aa8d170998d907c1f0 Mon Sep 17 00:00:00 2001 From: Kevin Carrogan Date: Wed, 11 Dec 2024 12:16:49 +0000 Subject: [PATCH] Add comment about removing order by --- .../0074_update_licence_decision_denial_reasons.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/api/cases/migrations/0074_update_licence_decision_denial_reasons.py b/api/cases/migrations/0074_update_licence_decision_denial_reasons.py index ae5a57f4b9..3256aa415d 100644 --- a/api/cases/migrations/0074_update_licence_decision_denial_reasons.py +++ b/api/cases/migrations/0074_update_licence_decision_denial_reasons.py @@ -22,7 +22,10 @@ def update_licencedecision_denial_reasons(apps, schema_editor): .only("denial_reasons__id", "case__licence_decisions__id") .exclude(denial_reasons__id__isnull=True) # This removes refusals without any criteria .values_list("denial_reasons__id", "case__licence_decisions__id") - .order_by() # We need to remove the order_by to make sure the distinct works + # The AdviceManager orders by `created_at` and this affects the distinct + # so we remove the ordering completely to ensure the distinct workds as + # expected + .order_by() .distinct() )