summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorAdnan Umer <u.adnan@outlook.com>2018-04-19 15:09:54 +0500
committerTim Graham <timograham@gmail.com>2018-04-19 12:46:31 -0400
commitf2026ca5e29273771f4dba75ca99b8dd5812e047 (patch)
treeb8eb9af71f5220815e243e000d44392137267612 /django
parentec0319ff821492783f555917b61bceacddb77571 (diff)
Fixed #29337 -- Added __len__() & __bool__() to RawQuerySet.
Diffstat (limited to 'django')
-rw-r--r--django/db/models/query.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/django/db/models/query.py b/django/db/models/query.py
index e1f3ce8adf..f16af1e91d 100644
--- a/django/db/models/query.py
+++ b/django/db/models/query.py
@@ -1293,6 +1293,14 @@ class RawQuerySet:
if self._result_cache is None:
self._result_cache = list(self.iterator())
+ def __len__(self):
+ self._fetch_all()
+ return len(self._result_cache)
+
+ def __bool__(self):
+ self._fetch_all()
+ return bool(self._result_cache)
+
def __iter__(self):
self._fetch_all()
return iter(self._result_cache)