From 678c429f64cc189c6c7a0e09fd3efc985c4cf8c3 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 9 Apr 2024 16:05:00 +0100 Subject: [PATCH] Fixing test case. --- .../src/api/controllers/row/utils/basic.ts | 19 +++++++++++++++++++ .../src/api/controllers/row/utils/utils.ts | 11 +++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/packages/server/src/api/controllers/row/utils/basic.ts b/packages/server/src/api/controllers/row/utils/basic.ts index 2fb67b07d5..1fc84de9c7 100644 --- a/packages/server/src/api/controllers/row/utils/basic.ts +++ b/packages/server/src/api/controllers/row/utils/basic.ts @@ -1,6 +1,7 @@ // need to handle table name + field or just field, depending on if relationships used import { FieldType, Row, Table } from "@budibase/types" import { generateRowIdField } from "../../../../integrations/utils" +import { CONSTANT_INTERNAL_ROW_COLS } from "../../../../db/utils" function extractFieldValue({ row, @@ -20,6 +21,15 @@ function extractFieldValue({ return value } +export function getInternalRowId(row: Row, table: Table): string { + return extractFieldValue({ + row, + tableName: table._id!, + fieldName: "_id", + isLinked: false, + }) +} + export function generateIdForRow( row: Row | undefined, table: Table, @@ -78,6 +88,15 @@ export function basicProcessing({ thisRow._id = generateIdForRow(row, table, isLinked) thisRow.tableId = table._id thisRow._rev = "rev" + } else { + for (let internalColumn of CONSTANT_INTERNAL_ROW_COLS) { + thisRow[internalColumn] = extractFieldValue({ + row, + tableName: table._id!, + fieldName: internalColumn, + isLinked: false, + }) + } } return thisRow } diff --git a/packages/server/src/api/controllers/row/utils/utils.ts b/packages/server/src/api/controllers/row/utils/utils.ts index 49b6aff85b..f387a468cf 100644 --- a/packages/server/src/api/controllers/row/utils/utils.ts +++ b/packages/server/src/api/controllers/row/utils/utils.ts @@ -15,7 +15,12 @@ import { processFormulas, } from "../../../../utilities/rowProcessor" import { updateRelationshipColumns } from "./sqlUtils" -import { basicProcessing, generateIdForRow, fixArrayTypes } from "./basic" +import { + basicProcessing, + generateIdForRow, + fixArrayTypes, + getInternalRowId, +} from "./basic" import sdk from "../../../../sdk" import validateJs from "validate.js" @@ -125,7 +130,9 @@ export async function sqlOutputProcessing( let finalRows: { [key: string]: Row } = {} for (let row of rows as Row[]) { let rowId = row._id - if (!rowId) { + if (opts?.sqs) { + rowId = getInternalRowId(row, table) + } else if (!rowId) { rowId = generateIdForRow(row, table) row._id = rowId }