From 6a9f430a7bc4ac76ad8918d7ede144339aa36c6b Mon Sep 17 00:00:00 2001 From: Yash Mehrotra Date: Thu, 12 Sep 2024 09:46:48 +0530 Subject: [PATCH] fix: use single on conflict clause --- models/components.go | 4 ---- models/topology.go | 7 +------ 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/models/components.go b/models/components.go index 84d29f49..789a6c40 100644 --- a/models/components.go +++ b/models/components.go @@ -337,10 +337,6 @@ func (c *Component) Save(db *gorm.DB) error { Columns: []clause.Column{{Name: "topology_id"}, {Name: "type"}, {Name: "name"}, {Name: "parent_id"}}, UpdateAll: true, }, - clause.OnConflict{ - Columns: []clause.Column{{Name: "id"}}, - UpdateAll: true, - }, ).Create(c).Error if err != nil { diff --git a/models/topology.go b/models/topology.go index 7416ea1f..2bbe0e30 100644 --- a/models/topology.go +++ b/models/topology.go @@ -60,11 +60,6 @@ func (t *Topology) AsMap(removeFields ...string) map[string]any { } func (t *Topology) Save(db *gorm.DB) error { - err := db.Clauses(Topology{}.OnConflictClause(), - clause.OnConflict{ - Columns: []clause.Column{{Name: "id"}}, - DoUpdates: clause.AssignmentColumns([]string{"labels", "spec"}), - }, - ).Create(t).Error + err := db.Clauses(Topology{}.OnConflictClause()).Create(t).Error return err }