diff options
author | marcperrinoptel <marc.perrin@optelgroup.com> | 2022-04-25 15:17:33 -0400 |
---|---|---|
committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-04-26 06:19:18 +0200 |
commit | 4282fd468fd11a7db79307ba1c33a4960c299e4a (patch) | |
tree | 4bcfc7aade937e83a920dce84409781d480e8e6d /tests/aggregation | |
parent | dcebc5da4831d2982b26d00a9480ad538b5c5acf (diff) | |
download | django-4282fd468fd11a7db79307ba1c33a4960c299e4a.tar.gz |
Fixed #33655 -- Removed unnecessary constant from GROUP BY clause for QuerySet.exists().
Diffstat (limited to 'tests/aggregation')
-rw-r--r-- | tests/aggregation/tests.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/aggregation/tests.py b/tests/aggregation/tests.py index 61da0ebfe7..c6d73e8042 100644 --- a/tests/aggregation/tests.py +++ b/tests/aggregation/tests.py @@ -1434,6 +1434,18 @@ class AggregateTestCase(TestCase): ) self.assertTrue(publisher_qs.exists()) + def test_aggregation_filter_exists(self): + publishers_having_more_than_one_book_qs = ( + Book.objects.values("publisher") + .annotate(cnt=Count("isbn")) + .filter(cnt__gt=1) + ) + query = publishers_having_more_than_one_book_qs.query.exists( + using=connection.alias + ) + _, _, group_by = query.get_compiler(connection=connection).pre_sql_setup() + self.assertEqual(len(group_by), 1) + def test_aggregation_exists_annotation(self): published_books = Book.objects.filter(publisher=OuterRef("pk")) publisher_qs = Publisher.objects.annotate( |