mirror of
https://github.com/n8n-io/n8n
synced 2026-04-19 13:05:54 +02:00
fix(Google Cloud Firestore Node): Fix empty array serialization in jsonToDocument (#28213)
Co-authored-by: RomanDavydchuk <roman.davydchuk@n8n.io>
This commit is contained in:
@@ -90,7 +90,7 @@ export function jsonToDocument(value: string | number | IDataObject | IDataObjec
|
||||
return { booleanValue: value };
|
||||
} else if (value === null) {
|
||||
return { nullValue: null };
|
||||
} else if (value !== '' && !isNaN(value as number)) {
|
||||
} else if (value !== '' && typeof value !== 'object' && !isNaN(value as number)) {
|
||||
if (value.toString().indexOf('.') !== -1) {
|
||||
return { doubleValue: value };
|
||||
} else {
|
||||
|
||||
@@ -344,6 +344,10 @@ describe('GoogleFirebaseCloudFirestore > GenericFunctions', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should convert empty arrays', () => {
|
||||
expect(jsonToDocument([] as any)).toEqual({ arrayValue: { values: [] } });
|
||||
});
|
||||
|
||||
it('should handle edge cases', () => {
|
||||
expect(jsonToDocument(0)).toEqual({ integerValue: 0 });
|
||||
expect(jsonToDocument(NaN as any)).toEqual({});
|
||||
|
||||
Reference in New Issue
Block a user