diff options
| author | Simon Charette <charette.s@gmail.com> | 2018-12-06 10:40:49 -0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-12-06 14:55:35 -0500 |
| commit | 53269bcaaf1fc2ce4db797d7d8935d98a53494df (patch) | |
| tree | a9f49ce6d43a546f7e0c827424de6dca5a8fb634 /tests | |
| parent | 88619e6129fd8c6668242f1acc1465ca175d2948 (diff) | |
Fixed #30011 -- Fixed queries that reuse filtered aggregates.
Thanks Taqi Abbas and Raphael Kimmig for the report.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/aggregation/test_filter_argument.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/aggregation/test_filter_argument.py b/tests/aggregation/test_filter_argument.py index 54836178c4..63dee59464 100644 --- a/tests/aggregation/test_filter_argument.py +++ b/tests/aggregation/test_filter_argument.py @@ -79,3 +79,11 @@ class FilteredAggregateTests(TestCase): msg = 'Star cannot be used with filter. Please specify a field.' with self.assertRaisesMessage(ValueError, msg): Count('*', filter=Q(age=40)) + + def test_filtered_reused_subquery(self): + qs = Author.objects.annotate( + older_friends_count=Count('friends', filter=Q(friends__age__gt=F('age'))), + ).filter( + older_friends_count__gte=2, + ) + self.assertEqual(qs.get(pk__in=qs.values('pk')), self.a1) |
