Merge pull request #4129 from ioito/butfix/qx-tenant-cache

fix: 避免插入时出现duplicate primary key error
This commit is contained in:
yunion-ci-robot
2019-12-13 11:36:58 +08:00
committed by GitHub
+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
}