Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cover absolute path filter queries #72

Open
Marcono1234 opened this issue Mar 23, 2024 · 1 comment
Open

Cover absolute path filter queries #72

Marcono1234 opened this issue Mar 23, 2024 · 1 comment

Comments

@Marcono1234
Copy link
Contributor

Marcono1234 commented Mar 23, 2024

It might be good to add tests for using an absolute path (that is $ instead of @) in a filter selector, e.g. $[?$.a==1]. Currently the filter tests only seem to cover relative paths (@) or invalid selectors with absolute paths, but not any valid selectors with absolute paths.

Might be good to cover:

  • existence test without segment: $[?$]
  • some 'normal' filter expressions, e.g. $[?$.a==1]
  • using (...), e.g. $[?($.a==1)]
  • equals self: $[?$==$] (similar to Add filter test for equality with self #71)
  • equals with relative path
    • selector: $[?@[0] == $[0]] and $[?$[0] == @[0]]
    • document: [0, [0, 1], [1, 2]]
  • applying the filter selector to a nested value and making sure $ is evaluated absolute and not relative, for example:
    • selector: $.a[?$.b==2]
    • document: {"a": [{"b": 1}], "b": 2}

What do you think?

@gregsdennis
Copy link
Collaborator

gregsdennis commented Mar 24, 2024

{
"name": "absolute non-singular query, index, equal",
"selector": "$[?($[0, 0]==42)]",
"invalid_selector": true
},
{
"name": "absolute non-singular query, index, not equal",
"selector": "$[?($[0, 0]!=42)]",
"invalid_selector": true
},
{
"name": "absolute non-singular query, index, less-or-equal",
"selector": "$[?($[0, 0]<=42)]",
"invalid_selector": true
},
{
"name": "absolute non-singular query, name, equal",
"selector": "$[?($['a', 'a']==42)]",
"invalid_selector": true
},
{
"name": "absolute non-singular query, name, not equal",
"selector": "$[?($['a', 'a']!=42)]",
"invalid_selector": true
},
{
"name": "absolute non-singular query, name, less-or-equal",
"selector": "$[?($['a', 'a']<=42)]",
"invalid_selector": true
},
{
"name": "absolute non-singular query, combined, equal",
"selector": "$[?($[0, '0']==42)]",
"invalid_selector": true
},
{
"name": "absolute non-singular query, combined, not equal",
"selector": "$[?($[0, '0']!=42)]",
"invalid_selector": true
},
{
"name": "absolute non-singular query, combined, less-or-equal",
"selector": "$[?($[0, '0']<=42)]",
"invalid_selector": true
},
{
"name": "absolute non-singular query, wildcard, equal",
"selector": "$[?($.*==42)]",
"invalid_selector": true
},
{
"name": "absolute non-singular query, wildcard, not equal",
"selector": "$[?($.*!=42)]",
"invalid_selector": true
},
{
"name": "absolute non-singular query, wildcard, less-or-equal",
"selector": "$[?($.*<=42)]",
"invalid_selector": true
},
{
"name": "absolute non-singular query, slice, equal",
"selector": "$[?($[0:0]==42)]",
"invalid_selector": true
},
{
"name": "absolute non-singular query, slice, not equal",
"selector": "$[?($[0:0]!=42)]",
"invalid_selector": true
},
{
"name": "absolute non-singular query, slice, less-or-equal",
"selector": "$[?($[0:0]<=42)]",
"invalid_selector": true
},

What we need is absolute singular query tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants