From 55285b82cc3f801d65731ef13d8f3b21a88224f5 Mon Sep 17 00:00:00 2001 From: David Hoppenbrouwers Date: Sat, 8 Oct 2022 10:52:16 +0200 Subject: [PATCH] Fix thread with no comments not being shown --- db/sqlite.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/db/sqlite.py b/db/sqlite.py index 6957991..b88dcef 100644 --- a/db/sqlite.py +++ b/db/sqlite.py @@ -31,9 +31,10 @@ class DB: def get_threads(self, forum_id): return self._db().execute(''' - select t.thread_id, title, t.create_time, t.update_time, t.author_id, name, count(1) - from threads t, users, comments c - where forum_id = ? and user_id = t.author_id and t.thread_id = c.thread_id + select t.thread_id, title, t.create_time, t.update_time, t.author_id, name, count(c.thread_id) + from threads t, users + left join comments c on t.thread_id = c.thread_id + where forum_id = ? and user_id = t.author_id group by t.thread_id ''', (forum_id,)