@@ -25,7 +25,7 @@ func (sb *sqliteBackend) GetWorkflowInstances(ctx context.Context, afterInstance
25
25
if afterInstanceID != "" {
26
26
rows , err = tx .QueryContext (
27
27
ctx ,
28
- `SELECT i.id, i.execution_id, i.created_at, i.completed_at, i.queue
28
+ `SELECT i.id, i.execution_id, i.parent_instance_id, i.parent_execution_id, i.parent_schedule_event_id, i. created_at, i.completed_at, i.queue
29
29
FROM instances i
30
30
INNER JOIN (SELECT id, created_at FROM instances WHERE id = ? AND execution_id = ?) ii
31
31
ON i.created_at < ii.created_at OR (i.created_at = ii.created_at AND i.id < ii.id)
@@ -38,7 +38,7 @@ func (sb *sqliteBackend) GetWorkflowInstances(ctx context.Context, afterInstance
38
38
} else {
39
39
rows , err = tx .QueryContext (
40
40
ctx ,
41
- `SELECT i.id, i.execution_id, i.created_at, i.completed_at, i.queue
41
+ `SELECT i.id, i.execution_id, i.parent_instance_id, i.parent_execution_id, i.parent_schedule_event_id, i. created_at, i.completed_at, i.queue
42
42
FROM instances i
43
43
ORDER BY i.created_at DESC, i.id DESC
44
44
LIMIT ?` ,
@@ -55,9 +55,11 @@ func (sb *sqliteBackend) GetWorkflowInstances(ctx context.Context, afterInstance
55
55
56
56
for rows .Next () {
57
57
var id , executionID , queue string
58
+ var parentID , parentExecutionID * string
59
+ var parentScheduleEventID * int64
58
60
var createdAt time.Time
59
61
var completedAt * time.Time
60
- err = rows .Scan (& id , & executionID , & createdAt , & completedAt , & queue )
62
+ err = rows .Scan (& id , & executionID , & parentID , & parentExecutionID , & parentScheduleEventID , & createdAt , & completedAt , & queue )
61
63
if err != nil {
62
64
return nil , err
63
65
}
@@ -67,8 +69,16 @@ func (sb *sqliteBackend) GetWorkflowInstances(ctx context.Context, afterInstance
67
69
state = core .WorkflowInstanceStateFinished
68
70
}
69
71
72
+ var instance * core.WorkflowInstance
73
+ if parentID != nil {
74
+ parentInstance := core .NewWorkflowInstance (* parentID , * parentExecutionID )
75
+ instance = core .NewSubWorkflowInstance (id , executionID , parentInstance , * parentScheduleEventID )
76
+ } else {
77
+ instance = core .NewWorkflowInstance (id , executionID )
78
+ }
79
+
70
80
instances = append (instances , & diag.WorkflowInstanceRef {
71
- Instance : core . NewWorkflowInstance ( id , executionID ) ,
81
+ Instance : instance ,
72
82
CreatedAt : createdAt ,
73
83
CompletedAt : completedAt ,
74
84
State : state ,
@@ -92,15 +102,17 @@ func (sb *sqliteBackend) GetWorkflowInstance(ctx context.Context, instance *core
92
102
93
103
res := tx .QueryRowContext (
94
104
ctx ,
95
- `SELECT id, execution_id, created_at, completed_at, queue
105
+ `SELECT id, execution_id, parent_instance_id, parent_execution_id, parent_schedule_event_id, created_at, completed_at, queue
96
106
FROM instances WHERE id = ? AND execution_id = ?` ,
97
107
instance .InstanceID , instance .ExecutionID )
98
108
99
109
var id , executionID , queue string
110
+ var parentID , parentExecutionID * string
111
+ var parentScheduleEventID * int64
100
112
var createdAt time.Time
101
113
var completedAt * time.Time
102
114
103
- err = res .Scan (& id , & executionID , & createdAt , & completedAt , & queue )
115
+ err = res .Scan (& id , & executionID , & parentID , & parentExecutionID , & parentScheduleEventID , & createdAt , & completedAt , & queue )
104
116
if err != nil {
105
117
if err == sql .ErrNoRows {
106
118
return nil , nil
@@ -114,8 +126,15 @@ func (sb *sqliteBackend) GetWorkflowInstance(ctx context.Context, instance *core
114
126
state = core .WorkflowInstanceStateFinished
115
127
}
116
128
129
+ if parentID != nil {
130
+ parentInstance := core .NewWorkflowInstance (* parentID , * parentExecutionID )
131
+ instance = core .NewSubWorkflowInstance (id , executionID , parentInstance , * parentScheduleEventID )
132
+ } else {
133
+ instance = core .NewWorkflowInstance (id , executionID )
134
+ }
135
+
117
136
return & diag.WorkflowInstanceRef {
118
- Instance : core . NewWorkflowInstance ( id , executionID ) ,
137
+ Instance : instance ,
119
138
CreatedAt : createdAt ,
120
139
CompletedAt : completedAt ,
121
140
State : state ,
0 commit comments