Skip to content

Commit 9c472ce

Browse files
author
Javier Palacios
committed
Select proper default for output_field based on distinct value
1 parent 5c00f78 commit 9c472ce

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/django_mysql/models/aggregates.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from django.db.models import Aggregate, CharField
2+
from django_mysql.models.fields import SetCharField, ListCharField
23

34

45
class BitAnd(Aggregate):
@@ -24,8 +25,10 @@ def __init__(
2425
):
2526

2627
if "output_field" not in extra:
27-
# This can/will be improved to SetTextField or ListTextField
28-
extra["output_field"] = CharField()
28+
if distinct:
29+
extra['output_field'] = SetCharField(CharField())
30+
else:
31+
extra['output_field'] = ListCharField(CharField())
2932

3033
super().__init__(expression, **extra)
3134

0 commit comments

Comments
 (0)