From 3282d9f4edbe5d341a0fa2a8c62b435b3885ab64 Mon Sep 17 00:00:00 2001 From: varunkasyap Date: Mon, 2 Feb 2026 13:50:16 +0530 Subject: Fixed #36890 -- Supported StringAgg(distinct=True) on SQLite with the default delimiter. --- tests/aggregation/tests.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/aggregation/tests.py b/tests/aggregation/tests.py index bf6bf27031..0a975dcb52 100644 --- a/tests/aggregation/tests.py +++ b/tests/aggregation/tests.py @@ -3,6 +3,7 @@ import math import re from decimal import Decimal from itertools import chain +from unittest import skipUnless from django.core.exceptions import FieldError from django.db import NotSupportedError, connection @@ -579,6 +580,16 @@ class AggregateTestCase(TestCase): ) self.assertCountEqual(books["ratings"].split(","), ["3", "4", "4.5", "5"]) + @skipUnless(connection.vendor == "sqlite", "Special default case for SQLite.") + def test_distinct_on_stringagg_sqlite_special_case(self): + """ + Value(",") is the only delimiter usable on SQLite with distinct=True. + """ + books = Book.objects.aggregate( + ratings=StringAgg(Cast(F("rating"), CharField()), Value(","), distinct=True) + ) + self.assertCountEqual(books["ratings"].split(","), ["3.0", "4.0", "4.5", "5.0"]) + @skipIfDBFeature("supports_aggregate_distinct_multiple_argument") def test_raises_error_on_multiple_argument_distinct(self): message = ( @@ -589,7 +600,7 @@ class AggregateTestCase(TestCase): Book.objects.aggregate( ratings=StringAgg( Cast(F("rating"), CharField()), - Value(","), + Value(";"), distinct=True, ) ) -- cgit v1.3