mirror of
https://github.com/django/django.git
synced 2025-07-05 18:29:11 +00:00
Fixed #6899 -- Fixed a problem with boolean evaluation of empty querysets.
Based on patches from cide@ctmod.net and brodie. git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7417 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
cfb706385b
commit
ed23f00a00
@ -72,7 +72,8 @@ class _QuerySet(object):
|
|||||||
iter(self).next()
|
iter(self).next()
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
return bool(self._result_cache)
|
||||||
|
|
||||||
def __getitem__(self, k):
|
def __getitem__(self, k):
|
||||||
"Retrieve an item or slice from the set of results."
|
"Retrieve an item or slice from the set of results."
|
||||||
|
@ -584,6 +584,12 @@ Test that parallel iterators work.
|
|||||||
>>> i1.next()
|
>>> i1.next()
|
||||||
<Tag: t3>
|
<Tag: t3>
|
||||||
|
|
||||||
|
>>> qs = X.objects.all()
|
||||||
|
>>> bool(qs)
|
||||||
|
False
|
||||||
|
>>> bool(qs)
|
||||||
|
False
|
||||||
|
|
||||||
We can do slicing beyond what is currently in the result cache, too.
|
We can do slicing beyond what is currently in the result cache, too.
|
||||||
|
|
||||||
# FIXME!! This next test causes really weird PostgreSQL behaviour, but it's
|
# FIXME!! This next test causes really weird PostgreSQL behaviour, but it's
|
||||||
|
Loading…
x
Reference in New Issue
Block a user