Fixed key issue

This commit is contained in:
Mike Farah 2023-05-30 11:58:41 +10:00
parent d17216de3f
commit f6c3fab309
3 changed files with 6 additions and 3 deletions

View File

@ -130,7 +130,7 @@ func (n *CandidateNode) GetFileIndex() int {
func (n *CandidateNode) GetKey() string {
keyPrefix := ""
if n.IsMapKey {
keyPrefix = "key-"
keyPrefix = fmt.Sprintf("key-%v-", n.Value)
}
key := ""
if n.Key != nil {

View File

@ -131,7 +131,7 @@ will output
- p: a
isKey: false
tag: '!!map'
- p: a.c
- p: a.b
isKey: true
tag: '!!str'
- p: a.b
@ -140,6 +140,9 @@ will output
- p: a.b.0
isKey: false
tag: '!!str'
- p: a.c
isKey: true
tag: '!!str'
- p: a.c
isKey: false
tag: '!!str'

View File

@ -61,7 +61,7 @@ var loadScenarios = []expressionScenario{
document: `{something: {file: "thing.yml"}, over: {here: [{file: "thing.yml"}]}}`,
expression: `(.. | select(has("file"))) |= load("../../examples/" + .file)`,
expected: []string{
"D0, P[], (!!map)::{something: {a: apple is included, b: cool.}, over: {here: [{a: apple is included, b: cool.}]}}\n",
"D0, P[], (doc)::{something: {a: apple is included, b: cool.}, over: {here: [{a: apple is included, b: cool.}]}}\n",
},
},
{