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, TableRequest,
TableSourceType, TableSourceType,
DatasourcePlusQueryResponse, DatasourcePlusQueryResponse,
BBReferenceFieldSubType,
} from "@budibase/types" } from "@budibase/types"
import { OAuth2Client } from "google-auth-library" import { OAuth2Client } from "google-auth-library"
import { import {
@ -363,6 +364,7 @@ class GoogleSheetsIntegration implements DatasourcePlus {
rowIndex: json.extra?.idFilter?.equal?.rowNumber, rowIndex: json.extra?.idFilter?.equal?.rowNumber,
sheet, sheet,
row: json.body, row: json.body,
table: json.meta.table,
}) })
case Operation.DELETE: case Operation.DELETE:
return this.delete({ return this.delete({
@ -586,7 +588,12 @@ class GoogleSheetsIntegration implements DatasourcePlus {
return { sheet, row } return { sheet, row }
} }
async update(query: { sheet: string; rowIndex: number; row: any }) { async update(query: {
sheet: string
rowIndex: number
row: any
table: Table
}) {
try { try {
await this.connect() await this.connect()
const { sheet, row } = await this.getRowByIndex( const { sheet, row } = await this.getRowByIndex(
@ -602,6 +609,15 @@ class GoogleSheetsIntegration implements DatasourcePlus {
if (row[key] === null) { if (row[key] === null) {
row[key] = "" 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() await row.save()
return [ return [