mirror of
https://github.com/django/django.git
synced 2025-08-04 10:59:45 +00:00
Fixed #24687 -- Added select_related() validation for nested non-relational fields.
The removed test was added in the original select_related() validation
patch (45d4e43d2d
), but there doesn't
seem to be any reason for it.
Thanks Claude Paroz for help and review.
This commit is contained in:
parent
5171f56fae
commit
67732a9b18
7 changed files with 31 additions and 13 deletions
|
@ -134,12 +134,6 @@ class SelectRelatedTests(TestCase):
|
|||
orders = [o.genus.family.order.name for o in world]
|
||||
self.assertEqual(orders, ['Agaricales'])
|
||||
|
||||
def test_single_related_field(self):
|
||||
with self.assertNumQueries(1):
|
||||
species = Species.objects.select_related('genus__name')
|
||||
names = [s.genus.name for s in species]
|
||||
self.assertEqual(sorted(names), ['Amanita', 'Drosophila', 'Homo', 'Pisum'])
|
||||
|
||||
def test_field_traversal(self):
|
||||
with self.assertNumQueries(1):
|
||||
s = (Species.objects.all()
|
||||
|
@ -206,6 +200,10 @@ class SelectRelatedValidationTests(SimpleTestCase):
|
|||
with self.assertRaisesMessage(FieldError, self.non_relational_error % ('name', '(none)')):
|
||||
list(Domain.objects.select_related('name'))
|
||||
|
||||
def test_non_relational_field_nested(self):
|
||||
with self.assertRaisesMessage(FieldError, self.non_relational_error % ('name', 'family')):
|
||||
list(Species.objects.select_related('genus__name'))
|
||||
|
||||
def test_many_to_many_field(self):
|
||||
with self.assertRaisesMessage(FieldError, self.invalid_error % ('toppings', '(none)')):
|
||||
list(Pizza.objects.select_related('toppings'))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue