Merge branch 'main' into next

This commit is contained in:
GitHub Actions Bot 2024-08-23 03:54:28 +00:00
commit 98ecf20aca
3 changed files with 40 additions and 1 deletions

View File

@ -196,6 +196,32 @@ describe('transformToFilter', () => {
expect(filter).toEqual(expectedFilter);
});
it('should keep 0 value', () => {
const valuesWithZero = {
field1: 0,
field2: 'value2',
};
const expectedFilter = {
$and: [
{
field1: {
$eq: 0,
},
},
{
field2: {
$ne: 'value2',
},
},
],
};
const filter = transformToFilter(valuesWithZero, operators, getCollectionJoinField, collectionName);
expect(filter).toEqual(expectedFilter);
});
it('should handle null values', () => {
const valuesWithNull = {
field1: null,

View File

@ -144,7 +144,7 @@ export const transformToFilter = (
key = `${key}.${collectionField.targetKey || 'id'}`;
}
if (!value) {
if (!value && value !== 0 && value !== false) {
return null;
}

View File

@ -65,4 +65,17 @@ describe('removeNullCondition', () => {
const result = removeNullCondition(filter);
expect(result).toEqual(expected);
});
it('should keep 0 value', () => {
const filter = {
field1: 0,
field2: 'value2',
};
const expected = {
field1: 0,
field2: 'value2',
};
const result = removeNullCondition(filter);
expect(result).toEqual(expected);
});
});