mirror of
https://github.com/mikefarah/yq.git
synced 2024-12-19 20:19:04 +00:00
c6efd5519b
Allows more sophisticated functionality
22 lines
675 B
Go
22 lines
675 B
Go
package yqlib
|
|
|
|
func equalsOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
|
|
log.Debugf("-- equalsOperation")
|
|
return crossFunction(d, context, expressionNode, isEquals)
|
|
}
|
|
|
|
func isEquals(d *dataTreeNavigator, context Context, lhs *CandidateNode, rhs *CandidateNode) (*CandidateNode, error) {
|
|
value := false
|
|
|
|
lhsNode := unwrapDoc(lhs.Node)
|
|
rhsNode := unwrapDoc(rhs.Node)
|
|
|
|
if lhsNode.Tag == "!!null" {
|
|
value = (rhsNode.Tag == "!!null")
|
|
} else {
|
|
value = matchKey(lhsNode.Value, rhsNode.Value)
|
|
}
|
|
log.Debugf("%v == %v ? %v", NodeToString(lhs), NodeToString(rhs), value)
|
|
return createBooleanCandidate(lhs, value), nil
|
|
}
|