﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
33114	StringAgg() should set output_field to TextField.	Swen Kooij	ali sayyah	"Example:

{{{#!python
class MyModel(models.Model):
     name = models.TextField()

list(MyModel.objects.annotate(names=StringAgg('name', ',')))
}}}

Results in the error:

{{{
django.core.exceptions.FieldError: Expression contains mixed types: TextField, CharField. You must set output_field.
}}}

There are two possible work-arounds:

1. Derive from `StringAgg` and set the `output_field`:

       {{{#!python
       class TextStringAgg(StringAgg):
           output_field = TextField()
       }}}

2. Wrap the expression in `ExpressionWrapper`:

       {{{#!python
       ExpressionWrapper(StringAgg('name', ','), output_field=TextField())
       }}}

This seems to be a regression introduced in 3.2 as part of this change: https://github.com/django/django/commit/1e38f1191de21b6e96736f58df57dfb851a28c1f
"	Cleanup/optimization	closed	contrib.postgres	3.2	Normal	fixed		Simon Charette	Ready for checkin	1	0	0	0	0	0
