mirror of
https://github.com/mikefarah/yq.git
synced 2024-12-19 20:19:04 +00:00
Fixed has operator for top level node
This commit is contained in:
parent
286590b01e
commit
8f5270cc63
@ -24,8 +24,9 @@ func hasOperator(d *dataTreeNavigator, matchingNodes *list.List, pathNode *PathT
|
||||
candidate := el.Value.(*CandidateNode)
|
||||
|
||||
// grab the first value
|
||||
var contents = candidate.Node.Content
|
||||
switch candidate.Node.Kind {
|
||||
candidateNode := UnwrapDoc(candidate.Node)
|
||||
var contents = candidateNode.Content
|
||||
switch candidateNode.Kind {
|
||||
case yaml.MappingNode:
|
||||
candidateHasKey := false
|
||||
for index := 0; index < len(contents) && !candidateHasKey; index = index + 2 {
|
||||
|
@ -5,6 +5,14 @@ import (
|
||||
)
|
||||
|
||||
var hasOperatorScenarios = []expressionScenario{
|
||||
{
|
||||
skipDoc: true,
|
||||
document: `a: hello`,
|
||||
expression: `has("a")`,
|
||||
expected: []string{
|
||||
"D0, P[], (!!bool)::true\n",
|
||||
},
|
||||
},
|
||||
{
|
||||
description: "Has map key",
|
||||
document: `- a: "yes"
|
||||
|
Loading…
Reference in New Issue
Block a user