mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Fixed #19173 -- Made EmptyQuerySet a marker class only
The guarantee that no queries will be made when accessing results is done by new EmptyWhere class which is used for query.where and having. Thanks to Simon Charette for reviewing and valuable suggestions.
This commit is contained in:
parent
a843539af2
commit
a2396a4c8f
11 changed files with 96 additions and 177 deletions
|
@ -593,15 +593,17 @@ none
|
|||
|
||||
.. method:: none()
|
||||
|
||||
Returns an ``EmptyQuerySet`` — a ``QuerySet`` subclass that always evaluates to
|
||||
an empty list. This can be used in cases where you know that you should return
|
||||
an empty result set and your caller is expecting a ``QuerySet`` object (instead
|
||||
of returning an empty list, for example.)
|
||||
Calling none() will create a queryset that never returns any objects and no
|
||||
query will be executed when accessing the results. A qs.none() queryset
|
||||
is an instance of ``EmptyQuerySet``.
|
||||
|
||||
Examples::
|
||||
|
||||
>>> Entry.objects.none()
|
||||
[]
|
||||
>>> from django.db.models.query import EmptyQuerySet
|
||||
>>> isinstance(Entry.objects.none(), EmptyQuerySet)
|
||||
True
|
||||
|
||||
all
|
||||
~~~
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue