-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinsert_log.go
More file actions
37 lines (32 loc) · 868 Bytes
/
insert_log.go
File metadata and controls
37 lines (32 loc) · 868 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package seedling
import "github.com/mhiro2/seedling/internal/executor"
func toExecutorLogFn(fn func(InsertLog)) func(executor.LogEntry) {
if fn == nil {
return nil
}
return func(entry executor.LogEntry) {
fn(toInsertLog(entry))
}
}
func toInsertLog(entry executor.LogEntry) InsertLog {
return InsertLog{
Step: entry.Step,
Blueprint: entry.Blueprint,
Table: entry.Table,
Provided: entry.Provided,
FKBindings: toFKBindings(entry.FKBindings),
}
}
func toFKBindings(bindings []executor.FKBinding) []FKBinding {
out := make([]FKBinding, len(bindings))
for i, binding := range bindings {
out[i] = FKBinding{
ChildField: binding.ChildField,
ParentBlueprint: binding.ParentBlueprint,
ParentTable: binding.ParentTable,
ParentField: binding.ParentField,
Value: binding.Value,
}
}
return out
}