Use no path for simple value queries

This commit is contained in:
tidwall 2019-06-28 10:18:23 -07:00
parent 00b15d756e
commit ebf0b3fb77
2 changed files with 2 additions and 1 deletions

View File

@ -1226,7 +1226,7 @@ func parseArray(c *parseContext, i int, path string) (int, bool) {
if qval.Type == JSON {
res = qval.Get(rp.query.path)
} else {
if rp.query.path != "" && rp.query.path != "_" {
if rp.query.path != "" {
return false
}
res = qval

View File

@ -1850,5 +1850,6 @@ func TestQueryArrayValues(t *testing.T) {
assert(t, Get(json, `a*.#[0="Bob Dylan"]#|#`).String() == "1")
assert(t, Get(json, `a*.#[0="Bob Dylan 2"]#|#`).String() == "0")
assert(t, Get(json, `a*.#[%"John*"]#|#`).String() == "2")
assert(t, Get(json, `a*.#[_%"John*"]#|#`).String() == "0")
assert(t, Get(json, `a*.#[="123"]#|#`).String() == "1")
}