Skip to content

Commit

Permalink
Merge pull request #472 from sangkenlee/policy-dbupdate-fix
Browse files Browse the repository at this point in the history
gorm DB 관계 업데이트 시 제외 처리가 안 되어 중복 레코드 삽입시도되는 버그 수정
  • Loading branch information
ktkfree authored May 7, 2024
2 parents 05af7fa + 928bd08 commit 624efe6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/repository/policy-template.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (r *PolicyTemplateRepository) Update(ctx context.Context, policyTemplateId
}

if len(updateMap) > 0 {
err = tx.WithContext(ctx).Model(&policyTemplate).Limit(1).
err = tx.WithContext(ctx).Omit("PermittedOrganizations").Model(&policyTemplate).Limit(1).
Where("id = ?", policyTemplateId).Where("type = ?", "tks").
Updates(updateMap).Error

Expand Down
2 changes: 1 addition & 1 deletion internal/repository/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (r *PolicyRepository) Update(ctx context.Context, organizationId string, po
}

if len(updateMap) > 0 {
err = tx.WithContext(ctx).Model(&policy).Limit(1).
err = tx.WithContext(ctx).Omit("TargetClusters").Model(&policy).Limit(1).
Where("id = ?", policyId).
Updates(updateMap).Error

Expand Down

0 comments on commit 624efe6

Please sign in to comment.