From 30f099ac5948f65f8d6752fb92c15c69443aa714 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 6 May 2024 14:34:55 +0200 Subject: [PATCH] Fix google user --- .../server/src/integrations/googlesheets.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/packages/server/src/integrations/googlesheets.ts b/packages/server/src/integrations/googlesheets.ts index 8288a07846..688fee50ce 100644 --- a/packages/server/src/integrations/googlesheets.ts +++ b/packages/server/src/integrations/googlesheets.ts @@ -17,6 +17,7 @@ import { TableRequest, TableSourceType, DatasourcePlusQueryResponse, + BBReferenceFieldSubType, } from "@budibase/types" import { OAuth2Client } from "google-auth-library" import { @@ -363,6 +364,7 @@ class GoogleSheetsIntegration implements DatasourcePlus { rowIndex: json.extra?.idFilter?.equal?.rowNumber, sheet, row: json.body, + table: json.meta.table, }) case Operation.DELETE: return this.delete({ @@ -586,7 +588,12 @@ class GoogleSheetsIntegration implements DatasourcePlus { return { sheet, row } } - async update(query: { sheet: string; rowIndex: number; row: any }) { + async update(query: { + sheet: string + rowIndex: number + row: any + table: Table + }) { try { await this.connect() const { sheet, row } = await this.getRowByIndex( @@ -602,6 +609,15 @@ class GoogleSheetsIntegration implements DatasourcePlus { if (row[key] === null) { row[key] = "" } + + const { type, subtype, constraints } = query.table.schema[key] + const isDeprecatedSingleUser = + type === FieldType.BB_REFERENCE && + subtype === BBReferenceFieldSubType.USER && + constraints?.type !== "array" + if (isDeprecatedSingleUser && Array.isArray(row[key])) { + row[key] = row[key][0] + } } await row.save() return [