2020-11-03 23:48:43 +00:00
|
|
|
package yqlib
|
2020-10-16 01:29:26 +00:00
|
|
|
|
|
|
|
import (
|
2020-10-21 01:54:58 +00:00
|
|
|
"container/list"
|
2020-10-16 01:29:26 +00:00
|
|
|
)
|
|
|
|
|
2021-01-12 23:18:53 +00:00
|
|
|
func equalsOperator(d *dataTreeNavigator, matchingNodes *list.List, expressionNode *ExpressionNode) (*list.List, error) {
|
2020-10-16 01:29:26 +00:00
|
|
|
log.Debugf("-- equalsOperation")
|
2021-01-12 23:18:53 +00:00
|
|
|
return crossFunction(d, matchingNodes, expressionNode, isEquals)
|
2020-10-16 01:29:26 +00:00
|
|
|
}
|
|
|
|
|
2020-10-20 05:27:30 +00:00
|
|
|
func isEquals(d *dataTreeNavigator, lhs *CandidateNode, rhs *CandidateNode) (*CandidateNode, error) {
|
|
|
|
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
|
|
|
}
|