fix(Google Sheets Node): Incorrect read of 0 and false (#6525)

This commit is contained in:
Michael Kret 2023-06-23 14:24:31 +03:00 committed by GitHub
parent 38dc784d2e
commit 806d134602
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View file

@ -163,7 +163,7 @@ describe('Test Google Sheets, removeEmptyColumns', () => {
expect(result).toBeDefined();
expect(result).toEqual([
['id', 'col1', 'col3'],
['', 'A', 'C'], // TODO:should be [0, 'A', 'C'] ?
[0, 'A', 'C'],
[1, 'a', 'c'],
[2, 'd', 'f'],
[3, 'g', 'i'],

View file

@ -102,7 +102,9 @@ export function trimToFirstEmptyRow(data: SheetRangeData, includesRowNumber = tr
export function removeEmptyRows(data: SheetRangeData, includesRowNumber = true) {
const baseLength = includesRowNumber ? 1 : 0;
const notEmptyRows = data.filter((row) =>
row.slice(baseLength).some((cell) => cell || typeof cell === 'number'),
row
.slice(baseLength)
.some((cell) => cell || typeof cell === 'number' || typeof cell === 'boolean'),
);
if (includesRowNumber) {
notEmptyRows[0][0] = ROW_NUMBER;
@ -143,7 +145,9 @@ export function removeEmptyColumns(data: SheetRangeData) {
returnData.push(column);
}
}
return (returnData[0] || []).map((_, i) => returnData.map((row) => row[i] || ''));
return (returnData[0] || []).map((_, i) =>
returnData.map((row) => (row[i] === undefined ? '' : row[i])),
);
}
export function prepareSheetData(