Improve array search filter for nullable Guid properties#80
Merged
Conversation
Enhanced ArraySearchFilterAttribute to handle nullable Guid properties by using extension methods for non-nullable types and value extraction. Added tests for filtering with Guid arrays without attribute and updated Preferences model to include OrganizationUnitId with ArraySearchFilter.
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the ArraySearchFilterAttribute to properly handle nullable Guid properties by introducing extension methods that convert nullable types to their non-nullable equivalents and extract values. The key change is using AsNonNullable() and GetValueExpressionIfNullable() extension methods to handle nullable types in the filter expressions.
Key Changes:
- Modified
ArraySearchFilterAttributeto use extension methods for handling nullable types - Added test case for filtering with Guid arrays without the attribute
- Updated
Preferencesmodel to include nullableOrganizationUnitIdproperty withArraySearchFilterattribute
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/AutoFilterer/Attributes/ArraySearchFilterAttribute.cs | Updated expression building logic to handle nullable types using extension methods |
| tests/AutoFilterer.Tests/Environment/Models/Preferences.cs | Added nullable OrganizationUnitId property with ArraySearchFilter attribute for testing |
| tests/AutoFilterer.Tests/Environment/Dtos/PreferencesFilter_ArraySearchWithoutAttribute_Guid.cs | New DTO for testing Guid array filtering without attribute |
| tests/AutoFilterer.Tests/Attributes/ArraySearchAttributeTests.cs | Added test case for Guid array filtering without attribute |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.
Enhanced ArraySearchFilterAttribute to handle nullable Guid properties by using extension methods for non-nullable types and value extraction. Added tests for filtering with Guid arrays without attribute and updated Preferences model to include OrganizationUnitId with ArraySearchFilter.
Closes #77