From d14d8e41db5cdc5c6f998d20567d5587f7e9f552 Mon Sep 17 00:00:00 2001 From: Egor fureunoir Gorbunov Date: Tue, 7 Oct 2025 20:05:07 +0300 Subject: [PATCH] Fixes: 1) Replace `product_uuid` with `product_id` in stock filtering queries to ensure compatibility. Extra: Refactor annotations for consistency across `core/filters.py` and `core/graphene/schema.py`. --- core/filters.py | 4 ++-- core/graphene/schema.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/filters.py b/core/filters.py index ac71ee02..5fd261fa 100644 --- a/core/filters.py +++ b/core/filters.py @@ -276,8 +276,8 @@ class ProductFilter(FilterSet): ordering_param = self.data.get("order_by", "") - stock_with_price = Stock.objects.filter(product_uuid=OuterRef("pk"), price__gt=0) - stock_with_qty = Stock.objects.filter(product_uuid=OuterRef("pk"), quantity__gt=0) + stock_with_price = Stock.objects.filter(product_id=OuterRef("pk"), price__gt=0) + stock_with_qty = Stock.objects.filter(product_id=OuterRef("pk"), quantity__gt=0) qs = qs.annotate( has_price=Exists(stock_with_price), diff --git a/core/graphene/schema.py b/core/graphene/schema.py index a1dbe3ea..dcb1730f 100644 --- a/core/graphene/schema.py +++ b/core/graphene/schema.py @@ -163,8 +163,8 @@ class Query(ObjectType): .prefetch_related("images", "stocks") ) - stock_with_price = Stock.objects.filter(product_uuid=OuterRef("pk"), price__gt=0) - stock_with_qty = Stock.objects.filter(product_uuid=OuterRef("pk"), quantity__gt=0) + stock_with_price = Stock.objects.filter(product_id=OuterRef("pk"), price__gt=0) + stock_with_qty = Stock.objects.filter(product_id=OuterRef("pk"), quantity__gt=0) return ( base_qs.annotate(