Compare commits

..

2 Commits

Author SHA1 Message Date
8158fff075 fix: do nothing by duplicate key
Signed-off-by: SoXX <soxx@fenpa.ws>
2024-07-03 10:28:22 +02:00
83fdd336a3 fix: do nothing by duplicate key
Signed-off-by: SoXX <soxx@fenpa.ws>
2024-07-03 10:19:15 +02:00
2 changed files with 5 additions and 2 deletions

View File

@ -188,7 +188,10 @@ func CreateTagAlias(ctx context.Context, db *gorm.DB, tagAliasName models.Anthro
return &otterError.EntityValidationFailed{Reason: otterError.AnthroveTagIDEmpty}
}
result := db.WithContext(ctx).Create(&models.TagAlias{
result := db.WithContext(ctx).Clauses(clause.OnConflict{
Columns: []clause.Column{{Name: "name"}},
DoNothing: true,
}).Create(&models.TagAlias{
Name: string(tagAliasName),
TagID: string(tagID),
})

View File

@ -328,7 +328,7 @@ func TestCreateTagAlias(t *testing.T) {
tagAliasName: validTagAliasName01,
tagID: validTagID,
},
wantErr: true,
wantErr: false,
},
{
name: "Test 6: Invalide tagID",