From 0d93a37a5cbabb70c4ff3a9fcdd118f8bb9cc971 Mon Sep 17 00:00:00 2001 From: Mikkel <4072916+Mikk3@users.noreply.github.com> Date: Tue, 31 May 2022 14:43:56 +0200 Subject: [PATCH] Fjern return None i fetchall hvis rowcount er 0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Slipper for at håndtere None type i tilfælde vi har en tom tråd, eller grupper uden opslag osv.. --- aula/models.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/aula/models.py b/aula/models.py index 14c916e..1c3b6c5 100644 --- a/aula/models.py +++ b/aula/models.py @@ -35,7 +35,7 @@ class Group(tuple): WHERE group_id = %s """ cur.execute(sql_call, (self.group_id,)) - Posts = cur.fetchall() if cur.rowcount > 0 else None + Posts = cur.fetchall() result = [] for post_data in Posts: result.append(Post(post_data)) @@ -49,7 +49,7 @@ class Group(tuple): WHERE threads.group_id = %s """ cur.execute(sql_call, (self.group_id,)) - threads = cur.fetchall() if cur.rowcount > 0 else None + threads = cur.fetchall() result = [] for thread_data in threads: result.append(Thread(thread_data)) @@ -143,7 +143,7 @@ class Thread(tuple): ORDER BY created_date ASC """ cur.execute(sql_call, (self.thread_id,)) - messages = cur.fetchall() if cur.rowcount > 0 else None + messages = cur.fetchall() result = [] for message_data in messages: result.append(Message(message_data)) @@ -233,7 +233,7 @@ class User(tuple, UserMixin): ) """ cur.execute(sql_call, (self.user_id,)) - threads = cur.fetchall() if cur.rowcount > 0 else None + threads = cur.fetchall() result = [] for thread_data in threads: result.append(Thread(thread_data))