From 6c0b43bd1483d275f9508e59d405a1e4d4e5ea48 Mon Sep 17 00:00:00 2001 From: Untone Date: Wed, 28 Feb 2024 18:20:58 +0300 Subject: [PATCH] random-topic-shouts-patch-2 --- resolvers/reader.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/resolvers/reader.py b/resolvers/reader.py index 68638cd7..c338b656 100644 --- a/resolvers/reader.py +++ b/resolvers/reader.py @@ -461,11 +461,11 @@ async def load_shouts_random_top(_, _info, options): @query.field('load_shouts_random_topic') async def load_shouts_random_topic(_, info, limit: int = 10): - random_topic_subquery = random_topic_query(1) + random_topic_subquery = random_topic_query(1).subquery() q = ( - select(Shout, Topic) - .join(Shout.topics) - .join(random_topic_subquery, Topic.id == random_topic_subquery.c.id) + select(Topic, Shout) + .select_from(Topic) + .join(Shout, Shout.topics.any(Topic.id == random_topic_subquery.c.id)) .options(joinedload(Shout.authors)) .filter( and_(