From 4f322456e95464d2fba0c7cc1c199c5c44af6289 Mon Sep 17 00:00:00 2001 From: Egor fureunoir Gorbunov Date: Tue, 6 May 2025 17:18:57 +0300 Subject: [PATCH] Fix order sorting by changing ordering field to UUID Previously, orders with duplicate `human_readable_id` were sorted by `id`, which could lead to inconsistencies. Updated the code to sort by `uuid` to ensure a more reliable and unique ordering. This prevents potential issues when resolving duplicate entries. --- core/migrations/0018_alter_order_human_readable_id.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/migrations/0018_alter_order_human_readable_id.py b/core/migrations/0018_alter_order_human_readable_id.py index 5e3bd33f..d31e7b7d 100644 --- a/core/migrations/0018_alter_order_human_readable_id.py +++ b/core/migrations/0018_alter_order_human_readable_id.py @@ -13,7 +13,7 @@ def fix_duplicates(apps, schema_editor): ) for duplicate in duplicates: h_id = duplicate["human_readable_id"] - orders = Order.objects.filter(human_readable_id=h_id).order_by("id") + orders = Order.objects.filter(human_readable_id=h_id).order_by("uuid") for order in orders[1:]: new_id = order.human_readable_id while Order.objects.filter(human_readable_id=new_id).exists():