You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by ab...@apache.org on 2024/04/26 09:11:36 UTC
(incubator-devlake) branch main updated: fix: customize plugin can not update old data (#7389)
This is an automated email from the ASF dual-hosted git repository.
abeizn pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
The following commit(s) were added to refs/heads/main by this push:
new 6ab1d296c fix: customize plugin can not update old data (#7389)
6ab1d296c is described below
commit 6ab1d296c6a99b109ae443f8517d62ee2fc4b310
Author: abeizn <zi...@merico.dev>
AuthorDate: Fri Apr 26 17:11:31 2024 +0800
fix: customize plugin can not update old data (#7389)
* fix: customize plugin can not update old data
* fix: recover pipeline_plan
* fix: e2e test
---
backend/impls/dalgorm/dalgorm.go | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/backend/impls/dalgorm/dalgorm.go b/backend/impls/dalgorm/dalgorm.go
index a3de41123..ba3bcdb61 100644
--- a/backend/impls/dalgorm/dalgorm.go
+++ b/backend/impls/dalgorm/dalgorm.go
@@ -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)
}