feat(server): enhance filter handling by allowing null values and updating tests for undefined/null elements

This commit is contained in:
Melvin Chia
2025-11-16 00:28:28 +08:00
parent 3e02418f9d
commit 07b1bfcafa
2 changed files with 5 additions and 2 deletions

View File

@@ -73,6 +73,7 @@ type FilterType<
filters: FilterType<TCollectionKey, TExpandConfig>
}
| undefined
| null
>
// Helper type for field selection object

View File

@@ -30,6 +30,7 @@ type MockFilter =
filters: MockFilter[]
}
| undefined
| null
// Helper function to create filter with proper typing
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -359,7 +360,7 @@ describe('recursivelyBuildFilter', () => {
expect(result.params).toEqual({})
})
it('should handle filter array with undefined elements', () => {
it('should handle filter array with undefined and null elements', () => {
const filter = createFilter([
undefined,
{
@@ -367,7 +368,8 @@ describe('recursivelyBuildFilter', () => {
operator: '=',
value: 'John'
},
undefined
undefined,
null
])
const result = recursivelyBuildFilter(filter)