From deed85d2f9147e6180014507ef4f5af3695b0c61 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sun, 3 Oct 2021 15:49:20 -0700 Subject: [PATCH] Handle null values while migrating release profiles --- .../Migration/162_release_profile_to_array.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/NzbDrone.Core/Datastore/Migration/162_release_profile_to_array.cs b/src/NzbDrone.Core/Datastore/Migration/162_release_profile_to_array.cs index 3c3e48252..6311dd577 100644 --- a/src/NzbDrone.Core/Datastore/Migration/162_release_profile_to_array.cs +++ b/src/NzbDrone.Core/Datastore/Migration/162_release_profile_to_array.cs @@ -27,8 +27,16 @@ namespace NzbDrone.Core.Datastore.Migration while (reader.Read()) { var id = reader.GetInt32(0); - var required = reader.GetString(1).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); - var ignored = reader.GetString(2).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); + var requiredObj = reader.GetValue(1); + var ignoredObj = reader.GetValue(2); + + var required = requiredObj == DBNull.Value + ? Enumerable.Empty() + : requiredObj.ToString().Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries); + + var ignored = ignoredObj == DBNull.Value + ? Enumerable.Empty() + : requiredObj.ToString().Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); using (var updateCmd = conn.CreateCommand()) {