#24760 closed Bug (wontfix)
Custom Aggregate: Return string (even if aggregate field is other type)
Reported by: | Helmut | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.7 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I'm writing a custom aggregate that should return a comma-separated string of numbers. In my specific case, the aggregate field is an IntegerField, and so Django tries to cast the aggregate result to int. So then I specified "is_ordinal = False" on the class, but it is still trying to cast to int.
It seems like the code just checks if is_ordinal is True. If it's anything other than true, it casts to the type of the aggregate field. Might this be a bug, or is there another way to get it to not cast to int?
Thanks.
Change History (3)
comment:1 by , 10 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
comment:2 by , 10 years ago
To provide a little more information - new aggregates allow you to set the output_field, so you get to decide the python type that comes back (CharField or TextField in your case).
I'm not sure if there's a bug there, however, there is a new expressions API in Django 1.8, and the code you referenced (
django.db.models.sql.aggregates
) is deprecated, so even if there is a bug there, it won't be fixed.