Ticket #29530: 29530.diff

File 29530.diff, 954 bytes (added by Mariusz Felisiak, 6 years ago)

Regression test.

  • tests/annotations/tests.py

    diff --git a/tests/annotations/tests.py b/tests/annotations/tests.py
    index 4fc7e6f047..71d1822549 100644
    a b class NonAggregateAnnotationTestCase(TestCase):  
    569569            Book.objects.annotate(is_book=True)
    570570        with self.assertRaisesMessage(TypeError, msg % ', '.join([str(BooleanField()), 'True'])):
    571571            Book.objects.annotate(BooleanField(), Value(False), is_book=True)
     572
     573    def test_multiple_annotation_with_m2m(self):
     574        qs = Author.objects.filter(
     575            friends__age=35,
     576        ).annotate(
     577            jacob_name=F('friends__name'),
     578        ).filter(
     579            friends__age=29,
     580        ).annotate(
     581            james_name=F('friends__name'),
     582        ).values('jacob_name', 'james_name')
     583        self.assertCountEqual(
     584            qs,
     585            [{'jacob_name': 'Jacob Kaplan-Moss', 'james_name': 'James Bennett'}],
     586        )
Back to Top