Fix groups not transferring when merging tags (#6127)

* Add test for group when merging tags
* Fix groups not reallocated when merging tags
This commit is contained in:
WithoutPants 2025-10-13 13:13:23 +11:00 committed by GitHub
parent 2ed9e5332d
commit 72c9c436be
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 0 deletions

View file

@ -790,6 +790,7 @@ func (qb *TagStore) Merge(ctx context.Context, source []int, destination int) er
imagesTagsTable: imageIDColumn, imagesTagsTable: imageIDColumn,
"performers_tags": "performer_id", "performers_tags": "performer_id",
"studios_tags": "studio_id", "studios_tags": "studio_id",
groupsTagsTable: "group_id",
} }
args = append(args, destination) args = append(args, destination)

View file

@ -931,6 +931,8 @@ func TestTagMerge(t *testing.T) {
tagIdxWithGallery, tagIdxWithGallery,
tagIdx1WithGallery, tagIdx1WithGallery,
tagIdx2WithGallery, tagIdx2WithGallery,
tagIdx1WithGroup,
tagIdx2WithGroup,
} }
var srcIDs []int var srcIDs []int
for _, idx := range srcIdxs { for _, idx := range srcIdxs {
@ -1024,6 +1026,18 @@ func TestTagMerge(t *testing.T) {
assert.Contains(studioTagIDs, destID) assert.Contains(studioTagIDs, destID)
// ensure group points to new tag
group, err := db.Group.Find(ctx, groupIDs[groupIdxWithTwoTags])
if err != nil {
return err
}
if err := group.LoadTagIDs(ctx, db.Group); err != nil {
return err
}
groupTagIDs := group.TagIDs.List()
assert.Contains(groupTagIDs, destID)
return nil return nil
}); err != nil { }); err != nil {
t.Error(err.Error()) t.Error(err.Error())