mirror of
https://github.com/mikefarah/yq.git
synced 2024-12-19 20:19:04 +00:00
Fixed equals operator for top level node
This commit is contained in:
parent
8f5270cc63
commit
90ec05be54
@ -32,11 +32,7 @@ func assignUpdateOperator(d *dataTreeNavigator, matchingNodes *list.List, pathNo
|
|||||||
candidate.UpdateFrom(rhsCandidate)
|
candidate.UpdateFrom(rhsCandidate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// // if there was nothing given, perhaps we are creating a new yaml doc
|
|
||||||
// if matchingNodes.Len() == 0 {
|
|
||||||
// log.Debug("started with nothing, returning LHS, %v", lhs.Len())
|
|
||||||
// return lhs, nil
|
|
||||||
// }
|
|
||||||
return matchingNodes, nil
|
return matchingNodes, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,10 +12,13 @@ func equalsOperator(d *dataTreeNavigator, matchingNodes *list.List, pathNode *Pa
|
|||||||
func isEquals(d *dataTreeNavigator, lhs *CandidateNode, rhs *CandidateNode) (*CandidateNode, error) {
|
func isEquals(d *dataTreeNavigator, lhs *CandidateNode, rhs *CandidateNode) (*CandidateNode, error) {
|
||||||
value := false
|
value := false
|
||||||
|
|
||||||
if lhs.Node.Tag == "!!null" {
|
lhsNode := UnwrapDoc(lhs.Node)
|
||||||
value = (rhs.Node.Tag == "!!null")
|
rhsNode := UnwrapDoc(rhs.Node)
|
||||||
|
|
||||||
|
if lhsNode.Tag == "!!null" {
|
||||||
|
value = (rhsNode.Tag == "!!null")
|
||||||
} else {
|
} else {
|
||||||
value = matchKey(lhs.Node.Value, rhs.Node.Value)
|
value = matchKey(lhsNode.Value, rhsNode.Value)
|
||||||
}
|
}
|
||||||
log.Debugf("%v == %v ? %v", NodeToString(lhs), NodeToString(rhs), value)
|
log.Debugf("%v == %v ? %v", NodeToString(lhs), NodeToString(rhs), value)
|
||||||
return createBooleanCandidate(lhs, value), nil
|
return createBooleanCandidate(lhs, value), nil
|
||||||
|
@ -5,6 +5,15 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var equalsOperatorScenarios = []expressionScenario{
|
var equalsOperatorScenarios = []expressionScenario{
|
||||||
|
{
|
||||||
|
skipDoc: true,
|
||||||
|
document: "cat",
|
||||||
|
document2: "dog",
|
||||||
|
expression: "select(fi==0) == select(fi==1)",
|
||||||
|
expected: []string{
|
||||||
|
"D0, P[], (!!bool)::false\n",
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
description: "Match string",
|
description: "Match string",
|
||||||
document: `[cat,goat,dog]`,
|
document: `[cat,goat,dog]`,
|
||||||
|
Loading…
Reference in New Issue
Block a user