diff --git a/django/db/models/query_utils.py b/django/db/models/query_utils.py index 88d3dc94ae..5d08786925 100644 --- a/django/db/models/query_utils.py +++ b/django/db/models/query_utils.py @@ -256,7 +256,6 @@ def select_related_descend(field, restricted, requested, load_fields, reverse=Fa " and traversed using select_related" " at the same time." % (field.model._meta.object_name, field.name)) - return False return True diff --git a/tests/defer/tests.py b/tests/defer/tests.py index 0c8320fdf5..b148c31906 100644 --- a/tests/defer/tests.py +++ b/tests/defer/tests.py @@ -128,9 +128,8 @@ class DeferTests(AssertionMixin, TestCase): Primary.objects.only("name").select_related("related")[0] def test_defer_foreign_keys_are_deferred_and_not_traversed(self): - # With a depth-based select_related, all deferred ForeignKeys are - # deferred instead of traversed. - with self.assertNumQueries(3): + # select_related() overrides defer(). + with self.assertNumQueries(1): obj = Primary.objects.defer("related").select_related()[0] self.assert_delayed(obj, 1) self.assertEqual(obj.related.id, self.s1.pk) diff --git a/tests/select_related_onetoone/tests.py b/tests/select_related_onetoone/tests.py index b047168795..3f45bba19c 100644 --- a/tests/select_related_onetoone/tests.py +++ b/tests/select_related_onetoone/tests.py @@ -1,7 +1,5 @@ from __future__ import unicode_literals -import unittest - from django.core.exceptions import FieldError from django.test import SimpleTestCase, TestCase @@ -175,7 +173,6 @@ class ReverseSelectRelatedTestCase(TestCase): self.assertEqual(p.child1.child4.value, p.child1.value) self.assertEqual(p.child1.child4.value4, 4) - @unittest.expectedFailure def test_inheritance_deferred(self): c = Child4.objects.create(name1='n1', name2='n2', value=1, value4=4) with self.assertNumQueries(1): @@ -192,10 +189,9 @@ class ReverseSelectRelatedTestCase(TestCase): with self.assertNumQueries(1): self.assertEqual(p.child1.name2, 'n2') - @unittest.expectedFailure def test_inheritance_deferred2(self): c = Child4.objects.create(name1='n1', name2='n2', value=1, value4=4) - qs = Parent2.objects.select_related('child1', 'child4').only( + qs = Parent2.objects.select_related('child1', 'child1__child4').only( 'id2', 'child1__value', 'child1__child4__value4') with self.assertNumQueries(1): p = qs.get(name2="n2") @@ -207,9 +203,8 @@ class ReverseSelectRelatedTestCase(TestCase): with self.assertNumQueries(1): self.assertEqual(p.child1.name2, 'n2') p = qs.get(name2="n2") - with self.assertNumQueries(1): + with self.assertNumQueries(0): self.assertEqual(p.child1.name1, 'n1') - with self.assertNumQueries(1): self.assertEqual(p.child1.child4.name1, 'n1')