feat: implement where filtering for arrays and values#50
Merged
Conversation
- 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements
wherefiltering as specified in #21.New Operation
where <condition>— Filter array elements or gate non-array valuesFor 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,
nullotherwise).Examples
Tests (10 integration tests)
where_age_greater_than— Numeric>comparisonwhere_string_comparison— String==comparisonwhere_null_check—!= nullfilterwhere_compound_and_condition—andcompound conditionwhere_or_condition—orcompound conditionwhere_negation—notnegationwhere_on_non_array_true— Boolean gate (passes)where_on_non_array_false— Boolean gate (blocks → null)where_empty_result— All filtered out → empty arraywhere_all_pass— All pass → unchanged arrayFixes #21