Skip to content

Commit

Permalink
fix: use single on conflict clause
Browse files Browse the repository at this point in the history
  • Loading branch information
yashmehrotra authored and moshloop committed Sep 12, 2024
1 parent 550eb22 commit 6a9f430
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 10 deletions.
4 changes: 0 additions & 4 deletions models/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 1 addition & 6 deletions models/topology.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 6a9f430

Please sign in to comment.