Fix update duplicate ids (#2965)

This commit is contained in:
WithoutPants
2022-09-30 18:44:37 +10:00
committed by GitHub
parent 51f4dd8a59
commit 9e44e13f6d
2 changed files with 66 additions and 13 deletions

View File

@@ -739,6 +739,22 @@ func Test_sceneQueryBuilder_UpdatePartialRelationships(t *testing.T) {
},
false,
},
{
"add identical galleries",
sceneIDs[sceneIdxWithGallery],
models.ScenePartial{
GalleryIDs: &models.UpdateIDs{
IDs: []int{galleryIDs[galleryIdx1WithImage], galleryIDs[galleryIdx1WithImage]},
Mode: models.RelationshipUpdateModeAdd,
},
},
models.Scene{
GalleryIDs: models.NewRelatedIDs(append(indexesToIDs(galleryIDs, sceneGalleries[sceneIdxWithGallery]),
galleryIDs[galleryIdx1WithImage],
)),
},
false,
},
{
"add tags",
sceneIDs[sceneIdxWithTwoTags],
@@ -759,6 +775,25 @@ func Test_sceneQueryBuilder_UpdatePartialRelationships(t *testing.T) {
},
false,
},
{
"add identical tags",
sceneIDs[sceneIdxWithTwoTags],
models.ScenePartial{
TagIDs: &models.UpdateIDs{
IDs: []int{tagIDs[tagIdx1WithDupName], tagIDs[tagIdx1WithDupName]},
Mode: models.RelationshipUpdateModeAdd,
},
},
models.Scene{
TagIDs: models.NewRelatedIDs(append(
[]int{
tagIDs[tagIdx1WithDupName],
},
indexesToIDs(tagIDs, sceneTags[sceneIdxWithTwoTags])...,
)),
},
false,
},
{
"add performers",
sceneIDs[sceneIdxWithTwoPerformers],
@@ -776,6 +811,22 @@ func Test_sceneQueryBuilder_UpdatePartialRelationships(t *testing.T) {
},
false,
},
{
"add identical performers",
sceneIDs[sceneIdxWithTwoPerformers],
models.ScenePartial{
PerformerIDs: &models.UpdateIDs{
IDs: []int{performerIDs[performerIdx1WithDupName], performerIDs[performerIdx1WithDupName]},
Mode: models.RelationshipUpdateModeAdd,
},
},
models.Scene{
PerformerIDs: models.NewRelatedIDs(append(indexesToIDs(performerIDs, scenePerformers[sceneIdxWithTwoPerformers]),
performerIDs[performerIdx1WithDupName],
)),
},
false,
},
{
"add movies",
sceneIDs[sceneIdxWithMovie],