From 47e6c5f978a0fd87873b2cf20cdbd95fe3a6ff12 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Thu, 4 Jan 2024 21:56:08 +0100 Subject: [PATCH] Fix bug in set last episode watch status as completed --- .../Controllers/Repositories/WatchStatusRepository.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/back/src/Kyoo.Core/Controllers/Repositories/WatchStatusRepository.cs b/back/src/Kyoo.Core/Controllers/Repositories/WatchStatusRepository.cs index ebdb3ccd..aee11760 100644 --- a/back/src/Kyoo.Core/Controllers/Repositories/WatchStatusRepository.cs +++ b/back/src/Kyoo.Core/Controllers/Repositories/WatchStatusRepository.cs @@ -378,7 +378,9 @@ public class WatchStatusRepository : IWatchStatusRepository } ) .Where(x => x.Status == null || x.Status.Status != WatchStatus.Completed) - .Select(x => x.Id) + // The as Guid? is here to add the nullability status of the queryable. + // Without this, FirstOrDefault returns new Guid() when no result is found (which is 16 0s and invalid in sql). + .Select(x => x.Id as Guid?) .FirstOrDefaultAsync(); } else if (status == WatchStatus.Completed)