From 24d42988c1e1eea617288464d0a44228f777a3ad Mon Sep 17 00:00:00 2001 From: Dave Hall Date: Wed, 8 Nov 2023 20:28:25 +0000 Subject: [PATCH] Revert "fix: speed up get deleted. remove unnecessary subquery" --- reversion/models.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/reversion/models.py b/reversion/models.py index c33d853c..4b245d92 100644 --- a/reversion/models.py +++ b/reversion/models.py @@ -168,11 +168,12 @@ def get_deleted(self, model, model_db=None): # conditional expressions are being supported since django 3.0 # DISTINCT ON works only for Postgres DB if connection.vendor == "postgresql" and django.VERSION >= (3, 0): - return ( + subquery = ( self.get_for_model(model, model_db=model_db) .filter(~models.Exists(model_qs)) .order_by("object_id", "-pk") .distinct("object_id") + .values("pk") ) else: subquery = (