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

Ordering operators aren't limited to numbers #51

Open
gibson042 opened this issue Aug 23, 2019 · 0 comments · May be fixed by #74
Open

Ordering operators aren't limited to numbers #51

gibson042 opened this issue Aug 23, 2019 · 0 comments · May be fixed by #74

Comments

@gibson042
Copy link

Per documentation:

Ordering operators >, >=, <, <= are only valid for numbers. Evaluating any other type with a comparison operator will yield a null value

But this library seems to follow native JavaScript rules instead, allowing e.g. strings to be used in comparisons with non-null results: https://runkit.com/embed/6yymqriowri5

{actual: true, expected: true, expression: "`0` < `1`", scenario: "number ordering_comparator number"}
{actual: true, expected: null, expression: "`0` < '1'", scenario: "number ordering_comparator string"}
{actual: true, expected: null, expression: "'a' < 'b'", scenario: "string ordering_comparator string"}
bespokebob added a commit to bespokebob/jmespath.js that referenced this issue Feb 17, 2021
According to the spec, ordering operators are only valid for numbers, but all types were being compared according to JavaScript rules instead. Fix the interpretation of ordering operators to conform to the spec and return null for any non-numbers.

Fixes jmespath#42
Fixes jmespath#51
@bespokebob bespokebob linked a pull request Feb 17, 2021 that will close this issue
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 a pull request may close this issue.

1 participant