django.db.models.Sum does not work on BooleanField
|Reported by:||wiz||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||master|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Models are Point -(fkey)-> Group and i'm trying to annotate Group queryset with a number of total points and a number of "active" points. Point.active is a BooleanField.
queryset = Group.objects.annotate( point_count = Count('point'), points_active = Sum('point__active'))
Exception Type: DatabaseError at /kiosks/wl/ Exception Value: function sum(boolean) does not exist LINE 1: ..."id", "kiwl_group"."title", "kiwl_group"."descr", SUM("kiwl_... ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts.
However, there is a Bug Report which is marked "fixed" and it looks like there is something i could to to actually get a Sum on BoolanField-s.
Change History (5)
comment:1 Changed 5 years ago by
|Triage Stage:||Unreviewed → Accepted|
|Version:||1.3 → SVN|