1
0
mirror of https://github.com/django/django.git synced 2025-10-23 21:59:11 +00:00

Fixed #29530 -- Fixed aliases ordering when chaining annotate() and filter().

This commit is contained in:
Mariusz Felisiak
2018-07-02 21:09:29 +02:00
committed by GitHub
parent b49b59b029
commit 0e64e046a4
2 changed files with 24 additions and 2 deletions

View File

@@ -569,3 +569,19 @@ class NonAggregateAnnotationTestCase(TestCase):
Book.objects.annotate(is_book=True)
with self.assertRaisesMessage(TypeError, msg % ', '.join([str(BooleanField()), 'True'])):
Book.objects.annotate(BooleanField(), Value(False), is_book=True)
def test_chaining_annotation_filter_with_m2m(self):
qs = Author.objects.filter(
name='Adrian Holovaty',
friends__age=35,
).annotate(
jacob_name=F('friends__name'),
).filter(
friends__age=29,
).annotate(
james_name=F('friends__name'),
).values('jacob_name', 'james_name')
self.assertCountEqual(
qs,
[{'jacob_name': 'Jacob Kaplan-Moss', 'james_name': 'James Bennett'}],
)