diff options
author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-03-04 09:51:52 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-04 09:51:52 +0100 |
commit | a46bc327e70f81b66800780edf3830f6137a89e3 (patch) | |
tree | d224ce2a89c317a911f7c5debb03728ff22f25d8 /tests/aggregation_regress | |
parent | b811364421c8eea0cf06459462cf1fd58184773b (diff) | |
download | django-a46bc327e70f81b66800780edf3830f6137a89e3.tar.gz |
Refs #11293 -- Added test for filtering aggregates with negated & operator.
Diffstat (limited to 'tests/aggregation_regress')
-rw-r--r-- | tests/aggregation_regress/tests.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/tests/aggregation_regress/tests.py b/tests/aggregation_regress/tests.py index 9582d90a96..fb9d4ca92b 100644 --- a/tests/aggregation_regress/tests.py +++ b/tests/aggregation_regress/tests.py @@ -1682,7 +1682,7 @@ class AggregationTests(TestCase): qs, ["Adrian Holovaty", "Peter Norvig"], lambda b: b.name ) - def test_ticket_11293(self): + def test_filter_aggregates_or_connector(self): q1 = Q(price__gt=50) q2 = Q(authors__count__gt=1) query = Book.objects.annotate(Count("authors")).filter(q1 | q2).order_by("pk") @@ -1692,6 +1692,18 @@ class AggregationTests(TestCase): attrgetter("pk"), ) + def test_filter_aggregates_negated_and_connector(self): + q1 = Q(price__gt=50) + q2 = Q(authors__count__gt=1) + query = ( + Book.objects.annotate(Count("authors")).filter(~(q1 & q2)).order_by("pk") + ) + self.assertQuerysetEqual( + query, + [self.b1.pk, self.b2.pk, self.b3.pk, self.b4.pk, self.b6.pk], + attrgetter("pk"), + ) + def test_ticket_11293_q_immutable(self): """ Splitting a q object to parts for where/having doesn't alter |