Skip to content

Commit

Permalink
fix: customize plugin can not update old data (#7389)
Browse files Browse the repository at this point in the history
* fix: customize plugin can not update old data

* fix: recover pipeline_plan

* fix: e2e test
  • Loading branch information
abeizn authored Apr 26, 2024
1 parent 696ed6e commit 6ab1d29
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions backend/impls/dalgorm/dalgorm.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,20 @@ func (d *Dalgorm) Create(entity interface{}, clauses ...dal.Clause) errors.Error
// CreateWithMap insert record to database
func (d *Dalgorm) CreateWithMap(entity interface{}, record map[string]interface{}) errors.Error {
d.unwrapDynamic(&entity, nil)
if record != nil {
if id, ok := record["id"]; ok && id != nil {
var columns []string
for column := range record {
columns = append(columns, column)
}
return d.convertGormError(buildTx(d.db, nil).Model(entity).Clauses(clause.OnConflict{
Columns: []clause.Column{{Name: "id"}},
DoUpdates: clause.AssignmentColumns(columns),
}).Create(record).Error)
} else {
return d.convertGormError(buildTx(d.db, nil).Model(entity).Clauses(clause.OnConflict{UpdateAll: true}).Create(record).Error)
}
}
return d.convertGormError(buildTx(d.db, nil).Model(entity).Clauses(clause.OnConflict{UpdateAll: true}).Create(record).Error)
}

Expand Down

0 comments on commit 6ab1d29

Please sign in to comment.