Skip to content

feat: implement where filtering for arrays and values#50

Merged
alvinreal merged 1 commit intomainfrom
fix/issue-21
Feb 21, 2026
Merged

feat: implement where filtering for arrays and values#50
alvinreal merged 1 commit intomainfrom
fix/issue-21

Conversation

@alvinreal
Copy link
Owner

Summary

Implements where filtering as specified in #21.

New Operation

where <condition> — Filter array elements or gate non-array values

For arrays, keeps only elements where the condition evaluates to truthy. For non-array values, acts as a boolean gate (returns the value if condition is true, null otherwise).

Examples

where .age > 18
where .status == "active"
where .name != null
where .score >= 50 and .verified == true
where .role == "admin" or .role == "super"
where not .deleted

Tests (10 integration tests)

  • where_age_greater_than — Numeric > comparison
  • where_string_comparison — String == comparison
  • where_null_check!= null filter
  • where_compound_and_conditionand compound condition
  • where_or_conditionor compound condition
  • where_negationnot negation
  • where_on_non_array_true — Boolean gate (passes)
  • where_on_non_array_false — Boolean gate (blocks → null)
  • where_empty_result — All filtered out → empty array
  • where_all_pass — All pass → unchanged array

Fixes #21

- Add where statement: filter array elements by condition expression
- Supports all expression types: comparisons, and/or, not, null checks
- Non-array values: applies as boolean gate (returns value or null)
- Empty result after filter returns empty array
- Add parser support for where keyword
- Add 10 integration tests covering all TDD scenarios

Fixes #21
@alvinreal alvinreal merged commit ad53de5 into main Feb 21, 2026
6 checks passed
@github-actions github-actions bot mentioned this pull request Mar 20, 2026
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.

Mapping: where filtering

1 participant