diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2009-06-06 13:35:33 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2009-06-06 13:35:33 +0000 |
| commit | 151d88af4e972547c40f1e70a3cd982f202f5c86 (patch) | |
| tree | db0a29fc314bcb765e587e8f482f3d9c16ba327a /tests/regressiontests | |
| parent | fa43a32bcbfd7b2e7092c664251406416ef280fd (diff) | |
Fixed #11082 -- Ensured that subqueries used in an exclude(X__in=) clause aren't pre-evaluated. Thanks to Henry Andrews for the report, and clement for the fix.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10929 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests')
| -rw-r--r-- | tests/regressiontests/queries/models.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/regressiontests/queries/models.py b/tests/regressiontests/queries/models.py index b5fa377496..3649d27171 100644 --- a/tests/regressiontests/queries/models.py +++ b/tests/regressiontests/queries/models.py @@ -1143,6 +1143,33 @@ True >>> r.save() >>> Ranking.objects.all() [<Ranking: 3: a1>, <Ranking: 2: a2>, <Ranking: 1: a3>] + +# Regression test for #10742: +# Queries used in an __in clause don't execute subqueries + +>>> subq = Author.objects.filter(num__lt=3000) +>>> qs = Author.objects.filter(pk__in=subq) +>>> list(qs) +[<Author: a1>, <Author: a2>] +# The subquery result cache should not be populated +>>> subq._result_cache is None +True + +>>> subq = Author.objects.filter(num__lt=3000) +>>> qs = Author.objects.exclude(pk__in=subq) +>>> list(qs) +[<Author: a3>, <Author: a4>] +# The subquery result cache should not be populated +>>> subq._result_cache is None +True + +>>> subq = Author.objects.filter(num__lt=3000) +>>> list(Author.objects.filter(Q(pk__in=subq) & Q(name='a1'))) +[<Author: a1>] +# The subquery result cache should not be populated +>>> subq._result_cache is None +True + """} # In Python 2.3 and the Python 2.6 beta releases, exceptions raised in __len__ |
