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:
@@ -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'}],
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user