couchbaselabs / gojsonsm

Go implementation of my JSONSM algorithm.
9 stars 7 forks source link

Matcher doesn't perform EXIST correctly on key with value of embedded map #90

Closed nelio2k closed 5 years ago

nelio2k commented 5 years ago

Given a data structure of:

    userData := map[string]interface{}{
        "KEY": map[string]interface{}{
            "internalKey": "value",
        },
    }

A filter expression of "KEY EXISTS" fails, even though technically it does exist. From what I can tell, matchExec sees KEY, and then goes ahead and does 2 more token gets, which are ":" followed by "{".

Something like this:

NEIL DEBUG testMap: map[[$%XDCRInternalKey%$]:TestDocKey Key:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA [$%XDCRInternalMeta%$]:map[AnotherXattr:TestValueString TestXattr:30]] NEIL DEBUG Expr: $doc.[$%XDCRInternalMeta%$] EXISTS NEIL DEBUG objStart going into objOrArray NEIL DEBUG tokenData: "[$%XDCRInternalKey%$]" NEIL DEBUG autostep tokenData: : NEIL DEBUG autostep2 tokenData: "TestDocKey" NEIL DEBUG KeyString: [$%XDCRInternalKey%$] NEIL DEBUG tokenData: "Key" NEIL DEBUG autostep tokenData: : NEIL DEBUG autostep2 tokenData: "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" NEIL DEBUG KeyString: Key NEIL DEBUG tokenData: "[$%XDCRInternalMeta%$]" NEIL DEBUG autostep tokenData: : NEIL DEBUG autostep2 tokenData: { NEIL DEBUG KeyString: [$%XDCRInternalMeta*%$] NEIL DEBUG KeyString found with token: 1 tokenData: { keyElem: :ops [0] @ exists @

So it sees that there is no operations for tokenData "{" and then bails, and the original [0] got lost.