mirror of
https://github.com/mikefarah/yq.git
synced 2025-01-26 00:15:36 +00:00
Fixed alternative operator
This commit is contained in:
parent
09c5ed24be
commit
d1548ead71
@ -9,6 +9,9 @@ func alternativeFunc(d *dataTreeNavigator, context Context, lhs *CandidateNode,
|
|||||||
if lhs == nil {
|
if lhs == nil {
|
||||||
return rhs, nil
|
return rhs, nil
|
||||||
}
|
}
|
||||||
|
if rhs == nil {
|
||||||
|
return lhs, nil
|
||||||
|
}
|
||||||
lhs.Node = unwrapDoc(lhs.Node)
|
lhs.Node = unwrapDoc(lhs.Node)
|
||||||
rhs.Node = unwrapDoc(rhs.Node)
|
rhs.Node = unwrapDoc(rhs.Node)
|
||||||
log.Debugf("Alternative LHS: %v", lhs.Node.Tag)
|
log.Debugf("Alternative LHS: %v", lhs.Node.Tag)
|
||||||
|
@ -19,6 +19,14 @@ var alternativeOperatorScenarios = []expressionScenario{
|
|||||||
"D0, P[], (doc)::a: bridge\n",
|
"D0, P[], (doc)::a: bridge\n",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
skipDoc: true,
|
||||||
|
expression: `.a // .b`,
|
||||||
|
document: `a: 2`,
|
||||||
|
expected: []string{
|
||||||
|
"D0, P[a], (!!int)::2\n",
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
description: "LHS is defined",
|
description: "LHS is defined",
|
||||||
expression: `.a // "hello"`,
|
expression: `.a // "hello"`,
|
||||||
|
Loading…
Reference in New Issue
Block a user