1
0
Fork 0
mirror of synced 2024-10-03 19:43:32 +13:00

Fixing test case.

This commit is contained in:
mike12345567 2024-04-09 16:05:00 +01:00
parent 2d36cf6c6a
commit 678c429f64
2 changed files with 28 additions and 2 deletions

View file

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

View file

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