2020-11-03 23:48:43 +00:00
|
|
|
package yqlib
|
2020-10-16 01:29:26 +00:00
|
|
|
|
2021-02-02 07:17:59 +00:00
|
|
|
func equalsOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
|
2020-10-16 01:29:26 +00:00
|
|
|
log.Debugf("-- equalsOperation")
|
2021-02-02 07:17:59 +00:00
|
|
|
return crossFunction(d, context, expressionNode, isEquals)
|
2020-10-16 01:29:26 +00:00
|
|
|
}
|
|
|
|
|
2021-02-02 07:17:59 +00:00
|
|
|
func isEquals(d *dataTreeNavigator, context Context, lhs *CandidateNode, rhs *CandidateNode) (*CandidateNode, error) {
|
2020-10-20 05:27:30 +00:00
|
|
|
value := false
|
2020-10-16 01:29:26 +00:00
|
|
|
|
2021-01-12 23:00:51 +00:00
|
|
|
lhsNode := unwrapDoc(lhs.Node)
|
|
|
|
rhsNode := unwrapDoc(rhs.Node)
|
2021-01-11 22:40:37 +00:00
|
|
|
|
|
|
|
if lhsNode.Tag == "!!null" {
|
|
|
|
value = (rhsNode.Tag == "!!null")
|
2020-10-20 05:27:30 +00:00
|
|
|
} else {
|
2021-01-11 22:40:37 +00:00
|
|
|
value = matchKey(lhsNode.Value, rhsNode.Value)
|
2020-10-16 01:29:26 +00:00
|
|
|
}
|
2020-10-20 05:27:30 +00:00
|
|
|
log.Debugf("%v == %v ? %v", NodeToString(lhs), NodeToString(rhs), value)
|
|
|
|
return createBooleanCandidate(lhs, value), nil
|
2020-10-16 01:29:26 +00:00
|
|
|
}
|