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:
James Campbell
2026-04-18 09:48:45 -04:00
committed by GitHub
parent f1dab3e295
commit 7094395cef
2 changed files with 5 additions and 1 deletions

View File

@@ -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 {

View File

@@ -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({});