Skip to content
This repository was archived by the owner on Oct 14, 2020. It is now read-only.

Fix filtering keys with punctuation#57

Closed
fredsted wants to merge 1 commit intoFlowCommunications:masterfrom
fredsted:fix-filter-by-key-with-punctuation
Closed

Fix filtering keys with punctuation#57
fredsted wants to merge 1 commit intoFlowCommunications:masterfrom
fredsted:fix-filter-by-key-with-punctuation

Conversation

@fredsted
Copy link

This is a simple fix inspired by #50 that fixes filtering keys containing non-letter characters, e.g. .data.tokens[?(@.Employee.FirstName)] or [?(@.neighbor-id == "192.168.1.1")] as also described in #50.

It basically causes the regex to match everything except whitespace and =. Let me know if it's too greedy, but all tests are passing.

@Daveiano
Copy link

Daveiano commented Sep 8, 2020

In your example, you mean by "Employee.FirstName" really that there is a key named "Employee.FirstName", not that you want to access the "FirstName" on the "Employee", right?

I need to access a sub-property inside the filter query like:

"publications": [
        {
            "id": "ea0d0106-6035-4ad0-a507-ed607e25f271",
            "title": "helloIT.jpg",
            "type": {
                "key": "image",
                "translations": [
                    {
                        "abbreviation": "A",
                        "language": "de",
                        "text": "Afbeelding"
                    },
                    {
                        "abbreviation": "I",
                        "language": "en",
                        "text": "Image"
                    }
                ]
            },
            "contentType": {
                "key": "profile-portrait",
                "translations": [
                    {
                        "abbreviation": "prp",
                        "language": "de",
                        "text": "Profilporträt"
                    },
                    {
                        "abbreviation": "prp",
                        "language": "en",
                        "text": "Profile Portrait"
                    }
                ]
            },
            "value": "i-need-this",
            "accountGroups": []
        }
    ],

What I want is

$.publications[?(@.contentType.key=='profile-portrait')].value

With this patch applied the error "Malformed filter query" is gone, but it seems that the query is not parsed correctly.

@fredsted
Copy link
Author

fredsted commented Sep 8, 2020

you mean by "Employee.FirstName" really that there is a key named "Employee.FirstName"

Yep, see the tests here, which demonstrates the problem.

@Daveiano
Copy link

Daveiano commented Sep 8, 2020

Ok, I see. So is there a way in the current implementation to use sub-properties in the filter string?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants