mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 03:56:16 +00:00
Merge branch 'main' into next
This commit is contained in:
commit
98ecf20aca
@ -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,
|
||||
|
@ -144,7 +144,7 @@ export const transformToFilter = (
|
||||
key = `${key}.${collectionField.targetKey || 'id'}`;
|
||||
}
|
||||
|
||||
if (!value) {
|
||||
if (!value && value !== 0 && value !== false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user