Fix google user

This commit is contained in:
Adria Navarro 2024-05-06 14:34:55 +02:00
parent 735572b4bf
commit 30f099ac59
1 changed files with 17 additions and 1 deletions

View File

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