🐛 Fix Google Sheet to handle 0 correctly (#1937)

* 🐛 Fix Google Sheet to handle 0 correctly

`if (condition) { statement }` will not be executed if the `condition` is `0` (number) so that appending 0 to Google Sheets results in an empty cell.
Checking if the value is `null` or `undefined` is enough to guarantee that `toString` is callable.

* 🐛 Add semicolon
This commit is contained in:
Kaito Udagawa 2021-07-03 19:46:30 +09:00 committed by GitHub
parent 05921de99a
commit 6d8ea4bff5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -486,8 +486,9 @@ export class GoogleSheet {
inputData.forEach((item) => { inputData.forEach((item) => {
rowData = []; rowData = [];
keyColumnOrder.forEach((key) => { keyColumnOrder.forEach((key) => {
if (item.hasOwnProperty(key) && item[key]) { const data = item[key];
rowData.push(item[key]!.toString()); if (item.hasOwnProperty(key) && data !== null && typeof data !== 'undefined') {
rowData.push(data.toString());
} else { } else {
rowData.push(''); rowData.push('');
} }