_QuerySet.__nonzero__ returns True for empty query sets with cached results
|Reported by:||brodie||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||queryset-refactor|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Given any sort of model with zero instances/rows, the following will currently occur:
>>> objects = Foo.objects.all() >>> bool(objects) False >>> bool(objects) True
_QuerySet.__nonzero__ unconditionally returns True when the result cache is populated, even if nothing is in the cache (i.e. there are no results).
I'm attaching a patch that fixes this behavior, and a test case for it.
Change History (7)
Changed 8 years ago by brodie
comment:1 Changed 8 years ago by anonymous
- Keywords qs-rf added; qs-ref removed
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset