From 27b846717f521c3c96885be9bac4ba2bbb8c9af2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Andr=C3=A9s=20Angulo?= Date: Thu, 17 Oct 2013 16:37:31 -0500 Subject: [PATCH] Fixed bug for count method when _none is True If my queryset have elements example: qs.all().count() => 10 q = qs.all().none() the count in queryset "q" must be 0 q.count() => 0 --- mongoengine/queryset/base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mongoengine/queryset/base.py b/mongoengine/queryset/base.py index ad75eccb..2a93e649 100644 --- a/mongoengine/queryset/base.py +++ b/mongoengine/queryset/base.py @@ -331,7 +331,7 @@ class BaseQuerySet(object): :meth:`skip` that has been applied to this cursor into account when getting the count """ - if self._limit == 0 and with_limit_and_skip: + if self._limit == 0 and with_limit_and_skip or self._none: return 0 return self._cursor.count(with_limit_and_skip=with_limit_and_skip) @@ -1491,4 +1491,4 @@ class BaseQuerySet(object): msg = ("Doc.objects()._ensure_indexes() is deprecated. " "Use Doc.ensure_indexes() instead.") warnings.warn(msg, DeprecationWarning) - self._document.__class__.ensure_indexes() \ No newline at end of file + self._document.__class__.ensure_indexes()