From 30fde61d4d571d82a216acf46888cef42f1e8cc6 Mon Sep 17 00:00:00 2001 From: adrinr Date: Mon, 27 Feb 2023 13:33:19 +0100 Subject: [PATCH] Handle deletes --- packages/server/src/integrations/googlesheets.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/server/src/integrations/googlesheets.ts b/packages/server/src/integrations/googlesheets.ts index d3caf0b944..587616adfc 100644 --- a/packages/server/src/integrations/googlesheets.ts +++ b/packages/server/src/integrations/googlesheets.ts @@ -308,10 +308,17 @@ class GoogleSheetsIntegration implements DatasourcePlus { } await sheet.setHeaderRow(headers) } else { - let newField = Object.keys(table.schema).find( + const updatedHeaderValues = [...sheet.headerValues] + + const newField = Object.keys(table.schema).find( key => !sheet.headerValues.includes(key) ) - await sheet.setHeaderRow([...sheet.headerValues, newField]) + + if (newField) { + updatedHeaderValues.push(newField) + } + + await sheet.setHeaderRow(updatedHeaderValues) } } catch (err) { console.error("Error updating table in google sheets", err)