1
0
mirror of https://github.com/django/django.git synced 2025-10-25 06:36:07 +00:00

Fixed #36048 -- Preferred ValueError to NotSupportedError for composite pk sanity checks.

These checks are not backend-dependent.
This commit is contained in:
Jacob Walls
2025-01-02 20:41:29 -05:00
committed by Sarah Boyce
parent 51df0dff3c
commit 46b3e7dd8c
4 changed files with 9 additions and 13 deletions

View File

@@ -1,4 +1,3 @@
from django.db import NotSupportedError
from django.db.models import Count, Q
from django.test import TestCase
@@ -82,7 +81,7 @@ class CompositePKAggregateTests(TestCase):
def test_count_distinct_not_supported(self):
with self.assertRaisesMessage(
NotSupportedError, "COUNT(DISTINCT) doesn't support composite primary keys"
ValueError, "COUNT(DISTINCT) doesn't support composite primary keys"
):
self.assertIsNone(
User.objects.annotate(comments__count=Count("comments", distinct=True))