From 61383b98965b788aa9a1fde3c18e1f2c1f02c537 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Wed, 24 Jun 2020 13:35:23 +0300 Subject: [PATCH] Stoken filtering: order by max_stoken to make sure we have a reliable order. --- django_etebase/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/django_etebase/views.py b/django_etebase/views.py index 4c528f1..f1e3802 100644 --- a/django_etebase/views.py +++ b/django_etebase/views.py @@ -105,7 +105,7 @@ class BaseViewSet(viewsets.ModelViewSet): aggr_fields = [Coalesce(Max(field), V(0)) for field in self.stoken_id_fields] max_stoken = Greatest(*aggr_fields) if len(aggr_fields) > 1 else aggr_fields[0] - queryset = queryset.annotate(max_stoken=max_stoken) + queryset = queryset.annotate(max_stoken=max_stoken).order_by('max_stoken') if stoken_rev is not None: queryset = queryset.filter(max_stoken__gt=stoken_rev.id)