mirror of
https://github.com/django/django.git
synced 2025-09-25 03:32:37 +00:00
Using querysets as an rvalue in filter() calls was causing an unnecessary
database query, due to a bool() call. This change stops that behaviour. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9715 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
d00c013cc8
commit
d068ad0c01
3 changed files with 17 additions and 0 deletions
|
@ -651,6 +651,10 @@ class QuerySet(object):
|
|||
obj = self.values("pk")
|
||||
return obj.query.as_nested_sql()
|
||||
|
||||
# When used as part of a nested query, a queryset will never be an "always
|
||||
# empty" result.
|
||||
value_annotation = True
|
||||
|
||||
class ValuesQuerySet(QuerySet):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(ValuesQuerySet, self).__init__(*args, **kwargs)
|
||||
|
@ -795,6 +799,10 @@ class EmptyQuerySet(QuerySet):
|
|||
# (it raises StopIteration immediately).
|
||||
yield iter([]).next()
|
||||
|
||||
# EmptyQuerySet is always an empty result in where-clauses (and similar
|
||||
# situations).
|
||||
value_annotation = False
|
||||
|
||||
|
||||
def get_cached_row(klass, row, index_start, max_depth=0, cur_depth=0,
|
||||
requested=None):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue