summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2012-04-11 21:11:22 +0000
committerAymeric Augustin <aymeric.augustin@m4x.org>2012-04-11 21:11:22 +0000
commit632b6a1a73bc47226e40dc0a9891c67138a2161c (patch)
tree273c63111f16d529f9cf895ae977c55d64811352 /tests
parente2548ec2a9e2f8dc733bcc72681fd28a34af4dbd (diff)
Fixed #17439 -- Prevented spurious queries for missing objects after prefetch_related has run.
That affects nullable foreign key, nullable one-to-one, and reverse one-to-one relations. git-svn-id: http://code.djangoproject.com/svn/django/trunk@17899 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/modeltests/prefetch_related/tests.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/modeltests/prefetch_related/tests.py b/tests/modeltests/prefetch_related/tests.py
index 035ae4aa10..c15294af1d 100644
--- a/tests/modeltests/prefetch_related/tests.py
+++ b/tests/modeltests/prefetch_related/tests.py
@@ -68,6 +68,14 @@ class PrefetchRelatedTests(TestCase):
self.assertQuerysetEqual(self.book2.authors.all(), [u"<Author: Charlotte>"])
+ def test_onetoone_reverse_no_match(self):
+ # Regression for #17439
+ with self.assertNumQueries(2):
+ book = Book.objects.prefetch_related('bookwithyear').all()[0]
+ with self.assertNumQueries(0):
+ with self.assertRaises(BookWithYear.DoesNotExist):
+ book.bookwithyear
+
def test_survives_clone(self):
with self.assertNumQueries(2):
lists = [list(b.first_time_authors.all())