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

Dot notation path containing a colon character fails to match #75

Open
oshadmi opened this issue Aug 26, 2021 · 5 comments
Open

Dot notation path containing a colon character fails to match #75

oshadmi opened this issue Aug 26, 2021 · 5 comments
Labels
enhancement New feature or request

Comments

@oshadmi
Copy link

oshadmi commented Aug 26, 2021

The following test fails due to the $.prod:id path

#[test]
fn colon_token_in_path() {
    setup();

    let payload = json!({
        "prod:id": "G637",
        "prod_name": "coffee table",
        "price": 194
    });

    select_and_then_compare("$.price", payload.clone(), json!([194]));

    select_and_then_compare("$.prod_name", payload.clone(), json!(["coffee table"]));

    select_and_then_compare("$.prod:id", payload.clone(), json!(["G637"]));
}

Returning an empty array []

test colon_token_in_path ... FAILED

failures:

---- colon_token_in_path stdout ----
thread 'colon_token_in_path' panicked at 'assertion failed: `(left == right)`
  left: `[]`,
 right: `[String("G637")]`: $.prod:id', tests/common.rs:41:5

@oshadmi
Copy link
Author

oshadmi commented Aug 26, 2021

Using the bracket notation is working well
select_and_then_compare("$[\"prod:id\"]", payload.clone(), json!(["G637"]));

@oshadmi oshadmi changed the title Path with a key containing a colon character fails to match Dot notation path containing a colon character fails to match Aug 26, 2021
@freestrings freestrings added the bug Something isn't working label Aug 29, 2021
@cburgmer
Copy link

Reading the draft specification I would say we might be converging on an interpretation of JSONPath where the colon : should not be considered a valid char in the dot notation: https://github.com/ietf-wg-jsonpath/draft-ietf-jsonpath-base/blob/main/draft-ietf-jsonpath-base.md#dot-selector.

@freestrings
Copy link
Owner

@oshadmi I agree with the "ietf-wg-jsonpath" specification. What do you think?

@oshadmi
Copy link
Author

oshadmi commented Sep 13, 2021

@freestrings For the current spec/implementation, we prefer to support the colon : as a valid character in the dot notation, since it is widely used with redis. I can try to contribute a fix for this. What do you think?

@freestrings
Copy link
Owner

I haven't thought about how to implement it, but how about an approach of turning additional features on and off with a setting?

@freestrings freestrings added enhancement New feature or request and removed bug Something isn't working labels Nov 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants