Skip to content

Commit cb38457

Browse files
committed
fix: adjust the slice length
debug
1 parent 2538e5e commit cb38457

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

result_set.go

+17-8
Original file line numberDiff line numberDiff line change
@@ -374,19 +374,20 @@ func (res ResultSet) scanRow(row *nebula.Row, colNames []string, rowType reflect
374374
}
375375

376376
func scanListCol(vals []*nebula.Value, listVal reflect.Value, sliceType reflect.Type) error {
377-
var listCol = reflect.MakeSlice(sliceType, len(vals), len(vals))
378-
for _, val := range vals {
379-
switch sliceType.Elem().Kind() {
380-
case reflect.Struct:
377+
var listCol = reflect.MakeSlice(sliceType, 0, len(vals))
378+
379+
switch sliceType.Elem().Kind() {
380+
case reflect.Struct:
381+
for _, val := range vals {
381382
ele := reflect.New(sliceType.Elem()).Elem()
382383
err := scanStructField(val, ele, sliceType.Elem())
383384
if err != nil {
384385
return err
385386
}
386387
listCol = reflect.Append(listCol, ele)
387-
default:
388-
return errors.New("scan: not support list type")
389388
}
389+
default:
390+
return errors.New("scan: not support list type")
390391
}
391392

392393
listVal.Set(listCol)
@@ -398,15 +399,23 @@ func scanStructField(val *nebula.Value, eleVal reflect.Value, eleType reflect.Ty
398399
vertex := val.GetVVal()
399400
if vertex != nil {
400401
tags := vertex.GetTags()
402+
vid := vertex.GetVid()
403+
401404
if len(tags) != 0 {
402-
tag := tags[0] // TODO: support multiple tags
405+
tag := tags[0]
406+
403407
props := tag.GetProps()
408+
props["_vid"] = vid
409+
tagName := tag.GetName()
410+
props["_tag_name"] = &nebula.Value{SVal: tagName}
411+
404412
err := scanValFromProps(props, eleVal, eleType)
405413
if err != nil {
406414
return err
407415
}
416+
return nil
408417
}
409-
return nil
418+
// no tags, continue
410419
}
411420

412421
edge := val.GetEVal()

0 commit comments

Comments
 (0)