Skip to content

Use JMESPath scalar equality for array containment - #378

Open
fhgffy wants to merge 1 commit into
jmespath:developfrom
fhgffy:fix/contains-array-boolean-equality-20261011
Open

fhgffy wants to merge 1 commit into
jmespath:developfrom
fhgffy:fix/contains-array-boolean-equality-20261011

Conversation

@fhgffy

@fhgffy fhgffy commented Oct 10, 2026

Copy link
Copy Markdown

contains([true], 1) currently returns true, although the scalar expression true == 1 returns false. The same problem occurs for false and zero because array membership uses Python equality.

Use the existing JMESPath comparator for array elements so membership agrees with scalar comparisons. String containment keeps its existing behavior. The comparator is imported at call time because the visitor already imports the functions module.

Tests cover both argument directions, float equivalents, matching booleans, numeric equality, null, strings, empty arrays, and a later matching element. All six boolean/number regressions fail on the original code. On Windows with Python 3.12.2, python -m pytest tests -q passes with 993 passed, 1 skipped, and 12 passing subtests; wheel and sdist builds also pass.

This leaves the separate nested-container equality issue in #372 and string argument handling in #360 to those changes.

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.

1 participant