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

'Filter Projections' not support int ? #138

Closed
iyaozhen opened this issue May 23, 2017 · 3 comments
Closed

'Filter Projections' not support int ? #138

iyaozhen opened this issue May 23, 2017 · 3 comments

Comments

@iyaozhen
Copy link

iyaozhen commented May 23, 2017

code:

from jmespath import search
test = {
    'data': {
        'fields': [
            {
                'class_id': 100,
                'orders': [1, 2, 3]
            },
            {
                'class_id': 200,
                'orders': [3, 2, 1]
            }
        ]
    }
}
print search("data.fields[?class_id=='100'].orders", test)
[]

debug:
image

print search("data.fields[?class_id==100].orders", test)

jmespath.exceptions.ParseError: invalid token: Parse error at column 23, token "100" (NUMBER), for expression:
"data.fields[?class_id==100].orders"

Must be that:

from jmespath import search
test = {
    'data': {
        'fields': [
            {
                'class_id': '100',
                'orders': [1, 2, 3]
            },
            {
                'class_id': 200,
                'orders': [3, 2, 1]
            }
        ]
    }
}
print search("data.fields[?class_id=='100'].orders", test)
[[1, 2, 3]]

It is like same bug with #132

@AnalyticsSupplyLLC
Copy link

If you look in the examples you will see that in order to filter by a number, the number must be surrounded by "back ticks"

search("data.fields[?class_id == `200`].orders",test)

That worked for me.

@iyaozhen
Copy link
Author

@AnalyticsSupplyLLC Thx, my mistake

@abonhomme
Copy link

This was super helpful for me. Is the need for backticks explicitly stated somewhere, besides the implicit usage in the examples and the grammar spec? If not, I'd be happy to make a PR with an update to the documentation; it would be helpful to know if I'm overlooking something.

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

No branches or pull requests

3 participants