fix: 避免插入时出现duplicate primary key error

This commit is contained in:
Qu Xuan
2019-12-13 10:43:34 +08:00
parent beff6e2287
commit c97fe6b74f
+2 -2
View File
@@ -298,9 +298,9 @@ func (manager *STenantCacheManager) Save(ctx context.Context, idStr string, name
obj.Domain = domain
obj.DomainId = domainId
obj.LastCheck = now
err = manager.TableSpec().Insert(obj)
err = manager.TableSpec().InsertOrUpdate(obj)
if err != nil {
return nil, err
return nil, errors.Wrap(err, "InsertOrUpdate")
} else {
return obj, nil
}