diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2009-01-08 05:16:21 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2009-01-08 05:16:21 +0000 |
| commit | d068ad0c01be9bb085c86a4e0c4dd047a85ce18d (patch) | |
| tree | c17b333ef31e628019908a7d55196ab9bf50d042 /tests | |
| parent | d00c013cc8477de9a75e4b4f5806034549e5a5e1 (diff) | |
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
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/regressiontests/queries/models.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/regressiontests/queries/models.py b/tests/regressiontests/queries/models.py index a3247bb460..05842ebe7b 100644 --- a/tests/regressiontests/queries/models.py +++ b/tests/regressiontests/queries/models.py @@ -1015,6 +1015,13 @@ performance problems on backends like MySQL. >>> Annotation.objects.filter(notes__in=Note.objects.filter(note="n1")) [<Annotation: a1>] +Nested queries should not evaluate the inner query as part of constructing the +SQL. This test verifies this: if the inner query is evaluated, the outer "in" +lookup will raise an EmptyResultSet exception (as the inner query returns +nothing). +>>> print Annotation.objects.filter(notes__in=Note.objects.filter(note="xyzzy")).query +SELECT ... + """} # In Python 2.3 and the Python 2.6 beta releases, exceptions raised in __len__ |
