feat: allowing in filtering to accept a collection as a parameter#711
Conversation
|
Hi, I’m Jit, a friendly security platform designed to help developers build secure applications from day zero with an MVS (Minimal viable security) mindset. In case there are security findings, they will be communicated to you as a comment inside the PR. Hope you’ll enjoy using Jit. Questions? Comments? Want to learn more? Get in touch with us. |
There was a problem hiding this comment.
Pull request overview
This PR enhances the TagField class by adding a new in(Collection<String>) method that allows users to pass Collections (List, Set, etc.) directly to the in() predicate without needing to convert them to arrays first. This improves the developer experience by removing the need for manual .toArray(new String[0]) conversions.
Changes:
- Added
in(Collection<String>)method to TagField class with proper documentation - Updated test data setup to use varied role assignments across users (improving test quality)
- Added comprehensive test coverage for the new Collection-based
in()method - Fixed an existing test assertion that was passing incorrectly due to homogeneous test data
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| redis-om-spring/src/main/java/com/redis/om/spring/metamodel/indexed/TagField.java | Adds new in(Collection<String>) method overload using List.copyOf() to convert the collection to an immutable list |
| tests/src/test/java/com/redis/om/spring/search/stream/EntityStreamDocsTest.java | Updates User test data to use varied roles per user, adds three new tests for the Collection-based in() method, and fixes testArrayLenToSimpleIndexedTagFieldInDocuments assertion to match the corrected test data |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This PR adds a new in(Collection values) method to the TagField class, allowing users to pass Collections (List, Set, etc.) directly to the in() predicate without needing to convert them to arrays first.
Motivation
Previously, users who had their filter values in a List or other Collection had to manually convert them to arrays using .toArray(new String[0]) before passing them to the in() method:
This was inconvenient and not intuitive, especially since Collections are a common way to store and pass around groups of values in Java.