From 1a5767edf0c79c9c918e25a1def8bbcf089a7a4e Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Tue, 30 Nov 2021 15:56:35 +0100 Subject: [PATCH] Improved find --- src/gismo_data/service/server_repository_service.py | 2 +- src/gismo_data/service/user_repository_service.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gismo_data/service/server_repository_service.py b/src/gismo_data/service/server_repository_service.py index 09ed488..8187820 100644 --- a/src/gismo_data/service/server_repository_service.py +++ b/src/gismo_data/service/server_repository_service.py @@ -46,7 +46,7 @@ class ServerRepositoryService(ServerRepositoryABC): def find_server_by_discord_id(self, discord_id: int) -> Optional[Server]: self._logger.trace(__name__, f'Send SQL command: {Server.get_select_by_discord_id_string(discord_id)}') result = self._context.select(Server.get_select_by_discord_id_string(discord_id)) - if len(result) == 0: + if len(result) == 0 or result is None: return None return Server( diff --git a/src/gismo_data/service/user_repository_service.py b/src/gismo_data/service/user_repository_service.py index 6212c82..4d94e70 100644 --- a/src/gismo_data/service/user_repository_service.py +++ b/src/gismo_data/service/user_repository_service.py @@ -55,7 +55,7 @@ class UserRepositoryService(UserRepositoryABC): def find_user_by_discord_id(self, discord_id: int) -> Optional[User]: self._logger.trace(__name__, f'Send SQL command: {User.get_select_by_discord_id_string(discord_id)}') result = self._context.select(User.get_select_by_discord_id_string(discord_id)) - if len(result) == 0: + if len(result) == 0 or result is None: return None return User(