mirror of
https://github.com/mikefarah/yq.git
synced 2026-07-06 04:45:39 +00:00
Fixed panic for syntax error when creating a map #2423
This commit is contained in:
parent
8e731ac13c
commit
55daf6d93c
@ -2,6 +2,7 @@ package yqlib
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"container/list"
|
"container/list"
|
||||||
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -34,6 +35,9 @@ func collectObjectOperator(d *dataTreeNavigator, originalContext Context, _ *Exp
|
|||||||
|
|
||||||
for el := context.MatchingNodes.Front(); el != nil; el = el.Next() {
|
for el := context.MatchingNodes.Front(); el != nil; el = el.Next() {
|
||||||
candidateNode := el.Value.(*CandidateNode)
|
candidateNode := el.Value.(*CandidateNode)
|
||||||
|
if len(candidateNode.Content) < len(first.Content) {
|
||||||
|
return Context{}, fmt.Errorf("CollectObject: mismatching node sizes; are you creating a map with mismatching key value pairs?")
|
||||||
|
}
|
||||||
|
|
||||||
for i := 0; i < len(first.Content); i++ {
|
for i := 0; i < len(first.Content); i++ {
|
||||||
log.Debugf("rotate[%v] = %v", i, NodeToString(candidateNode.Content[i]))
|
log.Debugf("rotate[%v] = %v", i, NodeToString(candidateNode.Content[i]))
|
||||||
|
|||||||
@ -12,6 +12,11 @@ var collectObjectOperatorScenarios = []expressionScenario{
|
|||||||
"D0, P[name], (!!str)::mike\n",
|
"D0, P[name], (!!str)::mike\n",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
skipDoc: true,
|
||||||
|
expression: `{"c": "a", "b", "d"}`,
|
||||||
|
expectedError: "CollectObject: mismatching node sizes; are you creating a map with mismatching key value pairs?",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
skipDoc: true,
|
skipDoc: true,
|
||||||
expression: `{"person": {"names": ["mike"]}} | .person.names[0]`,
|
expression: `{"person": {"names": ["mike"]}} | .person.names[0]`,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user