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 into
FlowCommunications:masterfrom
fredsted:fix-filter-by-key-with-punctuation
Closed

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

Conversation

@fredsted

Copy link
Copy Markdown

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

Daveiano commented Sep 8, 2020

Copy link
Copy Markdown

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

fredsted commented Sep 8, 2020

Copy link
Copy Markdown
Author

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

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

@Daveiano

Daveiano commented Sep 8, 2020

Copy link
Copy Markdown

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