Skip to content

Fix bool filter type to handle None values #189

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

denisfrm
Copy link

@denisfrm denisfrm commented Jan 8, 2025

This PR fixes the issue that find() is not able to handle None values as written in the issue #153

@michaelmior
Copy link
Collaborator

I would prefer not to remove the bool case that is currently handled, but otherwise this looks good.

@denisfrm
Copy link
Author

denisfrm commented Mar 9, 2025

I would prefer not to remove the bool case that is currently handled, but otherwise this looks good.

Hi @michaelmior , the problem is that the boolean type should not be converted. An example is this unit test:

    pytest.param(
        "foo[?flag = true].color",
        {
            "foo": [
                {"color": "blue", "flag": True},
                {"color": "green", "flag": 2},
                {"color": "red", "flag": "hi"},
                {"color": "gray", "flag": None},
            ]
        },
        ["blue"],
        id="boolean-filter-with-null",
    ),

When you want to search for colors only if flag is equal to true, if we convert the values ​​2, "hi". They will be converted to True. So the result of the test would be ["blue", "green", "red"] instead of ["blue"]

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

Successfully merging this pull request may close these issues.

2 participants