From 92e49c8ad9ca89b76cb5fa67b52a1dadb6586413 Mon Sep 17 00:00:00 2001 From: Untone Date: Fri, 1 Nov 2024 22:23:23 +0300 Subject: [PATCH] group-by-shout --- resolvers/reader.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/resolvers/reader.py b/resolvers/reader.py index 351a2178..689594c6 100644 --- a/resolvers/reader.py +++ b/resolvers/reader.py @@ -94,6 +94,7 @@ def query_with_stat(info): if has_field(info, "topics"): topics_subquery = ( select( + ShoutTopic.shout, json_array_builder( json_builder( "id", Topic.id, @@ -105,6 +106,7 @@ def query_with_stat(info): ) .outerjoin(Topic, ShoutTopic.topic == Topic.id) .where(ShoutTopic.shout == Shout.id) + .group_by(ShoutTopic.shout) .subquery() ) q = q.outerjoin(topics_subquery, topics_subquery.c.shout == Shout.id) @@ -126,6 +128,7 @@ def query_with_stat(info): ) .outerjoin(Author, ShoutAuthor.author == Author.id) .where(ShoutAuthor.shout == Shout.id) + .group_by(ShoutAuthor.shout) .subquery() ) q = q.outerjoin(authors_subquery, authors_subquery.c.shout == Shout.id)