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

expression.update() returns none #163

Open
3mrrrx opened this issue Jan 24, 2024 · 3 comments
Open

expression.update() returns none #163

3mrrrx opened this issue Jan 24, 2024 · 3 comments
Labels

Comments

@3mrrrx
Copy link

3mrrrx commented Jan 24, 2024

this might be a bug!

the following in example working in version 1.6.0 but returns None in version 1.6.1

jsonpath_expression = parse(  "$..UPPERCASE") 

def lowercase_value(orig,data,field):
    data[field] = data[field].lower()

dict_x = {
    "Data_cat": {
        "data_entry": [
            {"value": 0, "UPPERCASE": "UPPERCASE_A"},
            {"value": 2, "UPPERCASE": "UPPERCASE_B"},
        ]
    }
}
jsonpath_expression.update(dict_x, lowercase_value)

return in 1.6.0

dict_x = {
    "Data_cat": {
        "data_entry": [
            {"value": 0, "UPPERCASE": "uppercase_a"},
            {"value": 2, "UPPERCASE": "uppercase_b"},
        ]
    }
}

return in 1.6.1

dict_x = {
    "Data_cat": {
        "data_entry": [
            {"value": 0, "UPPERCASE": None},
            {"value": 2, "UPPERCASE": None},
        ]
    }
}
@michaelmior michaelmior added the bug label Feb 1, 2024
@michaelmior
Copy link
Collaborator

Thanks for flagging this! It looks like it was introduced in 7987969.

@michaelmior
Copy link
Collaborator

It looks like this is arguably not a bug, but certainly a change in behavior. Lambdas were changed to use the return value as the new value of the field. So the update function in your example above could be rewritten as

def lowercase_value(orig,data,field):
    return data[field].lower()

@jmkolbe
Copy link

jmkolbe commented Mar 5, 2024

Hi, thanks for looking into this and your explanation and your work on this valuable project in general.
For what it's worth, a change in behavior is not necessarily expected in a patch release. If this change is to stay, some migration documentation would be appreciated.

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

No branches or pull requests

3 participants