mirror of
				https://github.com/taigrr/yq
				synced 2025-01-18 04:53:17 -08:00 
			
		
		
		
	Unwrap node in get tag to return proper tag at root level
This commit is contained in:
		
							parent
							
								
									165949041d
								
							
						
					
					
						commit
						2faff7b05f
					
				| @ -42,7 +42,7 @@ func GetTagOperator(d *dataTreeNavigator, matchingNodes *list.List, pathNode *Pa | |||||||
| 
 | 
 | ||||||
| 	for el := matchingNodes.Front(); el != nil; el = el.Next() { | 	for el := matchingNodes.Front(); el != nil; el = el.Next() { | ||||||
| 		candidate := el.Value.(*CandidateNode) | 		candidate := el.Value.(*CandidateNode) | ||||||
| 		node := &yaml.Node{Kind: yaml.ScalarNode, Value: candidate.Node.Tag, Tag: "!!str"} | 		node := &yaml.Node{Kind: yaml.ScalarNode, Value: UnwrapDoc(candidate.Node).Tag, Tag: "!!str"} | ||||||
| 		lengthCand := &CandidateNode{Node: node, Document: candidate.Document, Path: candidate.Path} | 		lengthCand := &CandidateNode{Node: node, Document: candidate.Document, Path: candidate.Path} | ||||||
| 		results.PushBack(lengthCand) | 		results.PushBack(lengthCand) | ||||||
| 	} | 	} | ||||||
|  | |||||||
| @ -18,6 +18,14 @@ var tagOperatorScenarios = []expressionScenario{ | |||||||
| 			"D0, P[f], (!!str)::'!!seq'\n", | 			"D0, P[f], (!!str)::'!!seq'\n", | ||||||
| 		}, | 		}, | ||||||
| 	}, | 	}, | ||||||
|  | 	{ | ||||||
|  | 		skipDoc:    true, | ||||||
|  | 		document:   `{a: cat, b: 5, c: 3.2, e: true, f: []}`, | ||||||
|  | 		expression: `tag`, | ||||||
|  | 		expected: []string{ | ||||||
|  | 			"D0, P[], (!!str)::'!!map'\n", | ||||||
|  | 		}, | ||||||
|  | 	}, | ||||||
| 	{ | 	{ | ||||||
| 		description: "Convert numbers to strings", | 		description: "Convert numbers to strings", | ||||||
| 		document:    `{a: cat, b: 5, c: 3.2, e: true}`, | 		document:    `{a: cat, b: 5, c: 3.2, e: true}`, | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user