-
Notifications
You must be signed in to change notification settings - Fork 482
Open
Description
So I'm trying to do some aggregations and when I try to do sth like this:
actions_filter = Action.objects.filter(
target_object_id=OuterRef("pk"),
verb=ContentActivityType.VIEW_CONTENT,
)
view_subquery = Subquery(
actions_filter.values("target_object_id")
.annotate(views_count=Count("actor_object_id", distinct=True))
.values("views_count")[:1]
)
Content.objects.annotate(number_of_views=Coalesce(view_subquery, 0))
I get error:
django.db.utils.ProgrammingError: operator does not exist: character varying = bigint
LINE 1: ... "actstream_action" U0 WHERE U0."actor_object_id" = ("accoun...
^
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
And i have to cast the type of my ids in string each time:
target_object_id=Cast(OuterRef("pk"), output_field=CharField()),
Is there any way to fix this?
Why can't we change the *_object_id
to integers?
tamhv and renatooliveira
Metadata
Metadata
Assignees
Labels
No labels