Skip to content

Commit

Permalink
Merge pull request #1726 from actiontech/fix/workflow-export
Browse files Browse the repository at this point in the history
Fix/workflow export
  • Loading branch information
sjjian authored Aug 7, 2023
2 parents 33f7cfc + a6af9f4 commit aeccd36
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions sqle/model/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"github.com/jinzhu/gorm"
)

var UnScopedFunc = func(db *gorm.DB) *gorm.DB { return db.Unscoped() }

type WorkflowTemplate struct {
Model
Name string
Expand Down Expand Up @@ -810,7 +812,7 @@ func (s *Storage) GetWorkflowDetailById(id string) (*Workflow, bool, error) {

func (s *Storage) GetWorkflowExportById(id string) (*Workflow, bool, error) {
w := new(Workflow)
err := s.db.Preload("CreateUser", func(db *gorm.DB) *gorm.DB { return db.Unscoped() }).
err := s.db.Preload("CreateUser", UnScopedFunc).
Preload("Record").Where("id = ?", id).First(&w).Error
if err == gorm.ErrRecordNotFound {
return nil, false, nil
Expand All @@ -824,7 +826,8 @@ func (s *Storage) GetWorkflowExportById(id string) (*Workflow, bool, error) {
}

instanceRecordList := make([]*WorkflowInstanceRecord, 0)
err = s.db.Preload("Instance").Preload("Task").Preload("User").
err = s.db.Preload("Instance", UnScopedFunc).Preload("Task").
Preload("User", UnScopedFunc).
Where("workflow_record_id = ?", w.Record.ID).
Find(&instanceRecordList).Error
if err != nil {
Expand All @@ -842,7 +845,7 @@ func (s *Storage) GetWorkflowExportById(id string) (*Workflow, bool, error) {

steps := make([]*WorkflowStep, 0)
err = s.db.Where("workflow_record_id = ?", w.Record.ID).
Preload("OperationUser").
Preload("OperationUser", UnScopedFunc).
Find(&steps).Error
if err != nil {
return nil, false, errors.New(errors.ConnectStorageError, err)
Expand Down

0 comments on commit aeccd36

Please sign in to comment.