fix: do nothing by duplicate key
Signed-off-by: SoXX <soxx@fenpa.ws>
This commit is contained in:
parent
c20b9143db
commit
83fdd336a3
@ -188,7 +188,10 @@ func CreateTagAlias(ctx context.Context, db *gorm.DB, tagAliasName models.Anthro
|
|||||||
return &otterError.EntityValidationFailed{Reason: otterError.AnthroveTagIDEmpty}
|
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),
|
Name: string(tagAliasName),
|
||||||
TagID: string(tagID),
|
TagID: string(tagID),
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user