Skip to content

Commit cbf9812

Browse files
committed
fix strフラグを追加し、[]stringとして見做せない配列に対して処理を行わないようにした
1 parent 3f10525 commit cbf9812

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

pkg/inserter/common_inserter.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ func NewCommonInserter(client *firestore.Client) *CommonInserter {
3030
func (c *CommonInserter) CreateItem(ctx context.Context, cn, ID, refID string, item map[string]interface{}) error {
3131
item = c.tryParseDate(item)
3232
item = c.setRefs(item)
33-
log.Print(item)
3433

3534
var d *firestore.DocumentRef
3635
if ID == "" {
@@ -95,9 +94,11 @@ func (c *CommonInserter) setRefs(item map[string]interface{}) map[string]interfa
9594
switch vt := v.(type) {
9695
case []interface{}:
9796
new := make([]string, len(vt))
97+
isStr := true
9898
for i, vtv := range vt {
9999
vStr, ok := vtv.(string)
100100
if !ok {
101+
isStr = false
101102
break
102103
}
103104
if strings.HasPrefix(vStr, "$") && !reg.MatchString(vStr) {
@@ -114,7 +115,9 @@ func (c *CommonInserter) setRefs(item map[string]interface{}) map[string]interfa
114115
new[i] = n
115116
}
116117
}
117-
item[k] = new
118+
if isStr {
119+
item[k] = new
120+
}
118121
case map[string]interface{}:
119122
for vtk, vtv := range vt {
120123
if strings.HasPrefix(vtk, "$") && !reg.MatchString(vtk) {

0 commit comments

Comments
 (0)