Skip to content

Filter query existence tests and logical expressions #57

@jg-rp

Description

@jg-rp

When a singular filter query appears as part of a logical expression, we are incorrectly using the node's value rather than treating the query as an existence test.

Given the query $.users[?@.admin && @.score > 1] and the data:

{
  "users": [
    {
      "name": "Sue",
      "score": 100
    },
    {
      "name": "John",
      "score": 86,
      "admin": true
    },
    {
      "name": "Sally",
      "score": 84,
      "admin": false
    },
    {
      "name": "Jane",
      "score": 55
    }
  ],
  "moderator": "John"
}

We get

[
  {
    "name": "John",
    "score": 86,
    "admin": true
  }
]

And we should get

[
  {
    "name": "John",
    "score": 86,
    "admin": true
  },
  {
    "name": "Sally",
    "score": 84,
    "admin": false
  }
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    JSONPathbugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions