mirror of
				https://github.com/taigrr/yq
				synced 2025-01-18 04:53:17 -08:00 
			
		
		
		
	Equals now only compares scalars
This commit is contained in:
		
							parent
							
								
									63883d3000
								
							
						
					
					
						commit
						c284d4c6b1
					
				| @ -1,5 +1,7 @@ | ||||
| package yqlib | ||||
| 
 | ||||
| import "gopkg.in/yaml.v3" | ||||
| 
 | ||||
| func equalsOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) { | ||||
| 	log.Debugf("-- equalsOperation") | ||||
| 	return crossFunction(d, context, expressionNode, isEquals) | ||||
| @ -13,7 +15,7 @@ func isEquals(d *dataTreeNavigator, context Context, lhs *CandidateNode, rhs *Ca | ||||
| 
 | ||||
| 	if lhsNode.Tag == "!!null" { | ||||
| 		value = (rhsNode.Tag == "!!null") | ||||
| 	} else { | ||||
| 	} else if lhsNode.Kind == yaml.ScalarNode && rhsNode.Kind == yaml.ScalarNode { | ||||
| 		value = matchKey(lhsNode.Value, rhsNode.Value) | ||||
| 	} | ||||
| 	log.Debugf("%v == %v ? %v", NodeToString(lhs), NodeToString(rhs), value) | ||||
|  | ||||
| @ -14,6 +14,14 @@ var equalsOperatorScenarios = []expressionScenario{ | ||||
| 			"D0, P[], (!!bool)::false\n", | ||||
| 		}, | ||||
| 	}, | ||||
| 	{ | ||||
| 		skipDoc:    true, | ||||
| 		document:   "{a: { b: {things: \"\"}, f: [1], g: [] }}", | ||||
| 		expression: ".. | select(. == \"\")", | ||||
| 		expected: []string{ | ||||
| 			"D0, P[a b things], (!!str)::\"\"\n", | ||||
| 		}, | ||||
| 	}, | ||||
| 	{ | ||||
| 		description: "Match string", | ||||
| 		document:    `[cat,goat,dog]`, | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user