mirror of https://github.com/django/django.git
Refs #11293 -- Added test for filtering aggregates with negated & operator.
This commit is contained in:
parent
b811364421
commit
a46bc327e7
|
@ -1682,7 +1682,7 @@ class AggregationTests(TestCase):
|
||||||
qs, ["Adrian Holovaty", "Peter Norvig"], lambda b: b.name
|
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)
|
q1 = Q(price__gt=50)
|
||||||
q2 = Q(authors__count__gt=1)
|
q2 = Q(authors__count__gt=1)
|
||||||
query = Book.objects.annotate(Count("authors")).filter(q1 | q2).order_by("pk")
|
query = Book.objects.annotate(Count("authors")).filter(q1 | q2).order_by("pk")
|
||||||
|
@ -1692,6 +1692,18 @@ class AggregationTests(TestCase):
|
||||||
attrgetter("pk"),
|
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):
|
def test_ticket_11293_q_immutable(self):
|
||||||
"""
|
"""
|
||||||
Splitting a q object to parts for where/having doesn't alter
|
Splitting a q object to parts for where/having doesn't alter
|
||||||
|
|
Loading…
Reference in New Issue