From bc981bdae697736cfbc682f060f480e78de04dd8 Mon Sep 17 00:00:00 2001 From: Arthur Rio Date: Mon, 7 Mar 2022 18:41:30 -0700 Subject: [PATCH 1/2] Don't use deprecated property for emptiness check --- mongoengine/queryset/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mongoengine/queryset/base.py b/mongoengine/queryset/base.py index d3efe3f74..441cc0749 100644 --- a/mongoengine/queryset/base.py +++ b/mongoengine/queryset/base.py @@ -722,7 +722,7 @@ def with_id(self, object_id): :param object_id: the value for the id of the document to look up """ queryset = self.clone() - if not queryset._query_obj.empty: + if bool(queryset._query_obj): msg = "Cannot use a filter whilst using `with_id`" raise InvalidQueryError(msg) return queryset.filter(pk=object_id).first() From 669f3ba3d4ba5d258e746df1814d87b57c5ae414 Mon Sep 17 00:00:00 2001 From: Arthur Rio Date: Wed, 9 Mar 2022 16:45:12 -0700 Subject: [PATCH 2/2] Remove cast to bool --- mongoengine/queryset/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mongoengine/queryset/base.py b/mongoengine/queryset/base.py index 441cc0749..4ea6b10e1 100644 --- a/mongoengine/queryset/base.py +++ b/mongoengine/queryset/base.py @@ -722,7 +722,7 @@ def with_id(self, object_id): :param object_id: the value for the id of the document to look up """ queryset = self.clone() - if bool(queryset._query_obj): + if queryset._query_obj: msg = "Cannot use a filter whilst using `with_id`" raise InvalidQueryError(msg) return queryset.filter(pk=object_id).first()