From a2967d5204729771e3716c431ea98f8ee8562d3e Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Tue, 28 May 2013 13:35:08 -0400 Subject: [PATCH] Fixed #20242 - Added a regression test for prefetch_related. Issue was fixed by removal of chunked reads from QuerySet iteration in 70679243d1786e03557c28929f9762a119e3ac14. Thanks Simeon Visser for the patch. --- AUTHORS | 1 + tests/prefetch_related/tests.py | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/AUTHORS b/AUTHORS index 9c0af6a03a..80f277996b 100644 --- a/AUTHORS +++ b/AUTHORS @@ -594,6 +594,7 @@ answer newbie questions, and generally made Django that much better: I.S. van Oostveen viestards.lists@gmail.com George Vilches + Simeon Visser Vlado Zachary Voase Marijn Vriens diff --git a/tests/prefetch_related/tests.py b/tests/prefetch_related/tests.py index 3921153246..2e3fee6be6 100644 --- a/tests/prefetch_related/tests.py +++ b/tests/prefetch_related/tests.py @@ -107,6 +107,16 @@ class PrefetchRelatedTests(TestCase): qs = Book.objects.prefetch_related('first_time_authors') [b.first_time_authors.exists() for b in qs] + def test_in_and_prefetch_related(self): + """ + Regression test for #20242 - QuerySet "in" didn't work the first time + when using prefetch_related. This was fixed by the removal of chunked + reads from QuerySet iteration in + 70679243d1786e03557c28929f9762a119e3ac14. + """ + qs = Book.objects.prefetch_related('first_time_authors') + self.assertTrue(qs[0] in qs) + def test_clear(self): """ Test that we can clear the behavior by calling prefetch_related()