Skip to content

Commit

Permalink
Fix URL and aliases update nil dereference (stashapp#4075)
Browse files Browse the repository at this point in the history
* Clear field on null
  • Loading branch information
DingDongSoLong4 authored Sep 1, 2023
1 parent c38e05c commit 7a92143
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
12 changes: 10 additions & 2 deletions internal/api/resolver_mutation_performer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
Expand Down Expand Up @@ -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,
}
}
Expand Down
12 changes: 10 additions & 2 deletions internal/api/resolver_mutation_scene.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
Expand Down Expand Up @@ -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,
}
}
Expand Down

0 comments on commit 7a92143

Please sign in to comment.