handle object and array for and operator

This commit is contained in:
Pierre Noël 2022-02-14 17:24:08 +01:00
parent 3d3d51193e
commit af21bba606
2 changed files with 7 additions and 7 deletions

View File

@ -208,8 +208,8 @@ describe('Filtering API', () => {
[{ $null: '1' }],
[{ $null: 't' }],
[{ $null: 'anything' }],
[{ $null: '[]' }],
[{ $null: '{}' }],
[{ $null: ['anything'] }],
[{ $null: { anything: 'anything' } }],
[{ $notNull: false }],
[{ $notNull: 'false' }],
[{ $notNull: '0' }],
@ -239,8 +239,8 @@ describe('Filtering API', () => {
[{ $notNull: '1' }],
[{ $notNull: 't' }],
[{ $notNull: 'anything' }],
[{ $notNull: '[]' }],
[{ $notNull: '{}' }],
[{ $notNull: ['anything'] }],
[{ $notNull: { anything: 'anything' } }],
[{ $null: false }],
[{ $null: 'false' }],
[{ $null: '0' }],

View File

@ -287,10 +287,10 @@ const convertAndSanitizeFilters = (filters, schema) => {
// Handle operators
else {
if (isObject(value)) {
filters[key] = convertAndSanitizeFilters(value, schema);
} else if (['$null', '$notNull'].includes(key)) {
if (['$null', '$notNull'].includes(key)) {
filters[key] = parseType({ type: 'boolean', value: filters[key], forceCast: true });
} else if (isObject(value)) {
filters[key] = convertAndSanitizeFilters(value, schema);
}
}