Skip to content

Commit 02a8eac

Browse files
committed
INTPYTHON-935 Fix NotSupportedError for StringAgg(..., distinct=True)
1 parent ad359a9 commit 02a8eac

3 files changed

Lines changed: 14 additions & 3 deletions

File tree

django_mongodb_backend/aggregates.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def stddev_variance(self, compiler, connection):
8686
return aggregate(self, compiler, connection, operator=operator)
8787

8888

89-
def string_agg(self, compiler, connection): # noqa: ARG001
89+
def string_agg(self, compiler, connection, resolve_inner_expression=False): # noqa: ARG001
9090
raise NotSupportedError("StringAgg is not supported.")
9191

9292

docs/releases/6.0.x.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ Bug fixes
3535
that references in migrations don't need to be adjusted if models are later
3636
removed.
3737

38-
- Added a helpful ``NotSupportedError`` for ``QuerySet.extra(where=...)``
39-
rather than crashing with a more obscure exception.
38+
- Added a helpful ``NotSupportedError`` for ``QuerySet.extra(where=...)`` and
39+
``StringAgg(..., distinct=True)`` rather than crashing with more obscure
40+
exceptions.
4041

4142
Deprecated features
4243
-------------------

tests/aggregation_/test_stringagg.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,13 @@ class StringAggTests(TestCase):
99
def test_not_supprted(self):
1010
with self.assertRaisesMessage(NotSupportedError, "StringAgg is not supported."):
1111
list(Author.objects.aggregate(all_names=StringAgg("name", Value(","))))
12+
13+
def test_distinct(self):
14+
with self.assertRaisesMessage(NotSupportedError, "StringAgg is not supported."):
15+
Author.objects.aggregate(
16+
stringagg=StringAgg(
17+
"name",
18+
delimiter=Value(";"),
19+
distinct=True,
20+
)
21+
)

0 commit comments

Comments
 (0)