From 7a9214375b525957e58d6e2e956c4cb2f83bdadb Mon Sep 17 00:00:00 2001 From: DingDongSoLong4 <99329275+DingDongSoLong4@users.noreply.github.com> Date: Sat, 2 Sep 2023 01:00:50 +0200 Subject: [PATCH] Fix URL and aliases update nil dereference (#4075) * Clear field on null --- internal/api/resolver_mutation_performer.go | 12 ++++++++++-- internal/api/resolver_mutation_scene.go | 12 ++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/internal/api/resolver_mutation_performer.go b/internal/api/resolver_mutation_performer.go index 2c23f063a2b..dbdfe2160fc 100644 --- a/internal/api/resolver_mutation_performer.go +++ b/internal/api/resolver_mutation_performer.go @@ -201,8 +201,12 @@ func (r *mutationResolver) PerformerUpdate(ctx context.Context, input PerformerU Mode: models.RelationshipUpdateModeSet, } } else if translator.hasField("aliases") { + var values []string + if input.Aliases != nil { + values = stringslice.FromString(*input.Aliases, ",") + } updatedPerformer.Aliases = &models.UpdateStrings{ - Values: stringslice.FromString(*input.Aliases, ","), + Values: values, Mode: models.RelationshipUpdateModeSet, } } @@ -332,8 +336,12 @@ func (r *mutationResolver) BulkPerformerUpdate(ctx context.Context, input BulkPe Mode: input.AliasList.Mode, } } else if translator.hasField("aliases") { + var values []string + if input.Aliases != nil { + values = stringslice.FromString(*input.Aliases, ",") + } updatedPerformer.Aliases = &models.UpdateStrings{ - Values: stringslice.FromString(*input.Aliases, ","), + Values: values, Mode: models.RelationshipUpdateModeSet, } } diff --git a/internal/api/resolver_mutation_scene.go b/internal/api/resolver_mutation_scene.go index 12d89c9d8fc..4c338586c5e 100644 --- a/internal/api/resolver_mutation_scene.go +++ b/internal/api/resolver_mutation_scene.go @@ -200,8 +200,12 @@ func scenePartialFromInput(input models.SceneUpdateInput, translator changesetTr Mode: models.RelationshipUpdateModeSet, } } else if translator.hasField("url") { + var values []string + if input.URL != nil { + values = []string{*input.URL} + } updatedScene.URLs = &models.UpdateStrings{ - Values: []string{*input.URL}, + Values: values, Mode: models.RelationshipUpdateModeSet, } } @@ -381,8 +385,12 @@ func (r *mutationResolver) BulkSceneUpdate(ctx context.Context, input BulkSceneU Mode: input.Urls.Mode, } } else if translator.hasField("url") { + var values []string + if input.URL != nil { + values = []string{*input.URL} + } updatedScene.URLs = &models.UpdateStrings{ - Values: []string{*input.URL}, + Values: values, Mode: models.RelationshipUpdateModeSet, } }