Fixing test case.
This commit is contained in:
parent
2d36cf6c6a
commit
678c429f64
2 changed files with 28 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
||||||
// need to handle table name + field or just field, depending on if relationships used
|
// need to handle table name + field or just field, depending on if relationships used
|
||||||
import { FieldType, Row, Table } from "@budibase/types"
|
import { FieldType, Row, Table } from "@budibase/types"
|
||||||
import { generateRowIdField } from "../../../../integrations/utils"
|
import { generateRowIdField } from "../../../../integrations/utils"
|
||||||
|
import { CONSTANT_INTERNAL_ROW_COLS } from "../../../../db/utils"
|
||||||
|
|
||||||
function extractFieldValue({
|
function extractFieldValue({
|
||||||
row,
|
row,
|
||||||
|
@ -20,6 +21,15 @@ function extractFieldValue({
|
||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getInternalRowId(row: Row, table: Table): string {
|
||||||
|
return extractFieldValue({
|
||||||
|
row,
|
||||||
|
tableName: table._id!,
|
||||||
|
fieldName: "_id",
|
||||||
|
isLinked: false,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export function generateIdForRow(
|
export function generateIdForRow(
|
||||||
row: Row | undefined,
|
row: Row | undefined,
|
||||||
table: Table,
|
table: Table,
|
||||||
|
@ -78,6 +88,15 @@ export function basicProcessing({
|
||||||
thisRow._id = generateIdForRow(row, table, isLinked)
|
thisRow._id = generateIdForRow(row, table, isLinked)
|
||||||
thisRow.tableId = table._id
|
thisRow.tableId = table._id
|
||||||
thisRow._rev = "rev"
|
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
|
return thisRow
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,12 @@ import {
|
||||||
processFormulas,
|
processFormulas,
|
||||||
} from "../../../../utilities/rowProcessor"
|
} from "../../../../utilities/rowProcessor"
|
||||||
import { updateRelationshipColumns } from "./sqlUtils"
|
import { updateRelationshipColumns } from "./sqlUtils"
|
||||||
import { basicProcessing, generateIdForRow, fixArrayTypes } from "./basic"
|
import {
|
||||||
|
basicProcessing,
|
||||||
|
generateIdForRow,
|
||||||
|
fixArrayTypes,
|
||||||
|
getInternalRowId,
|
||||||
|
} from "./basic"
|
||||||
import sdk from "../../../../sdk"
|
import sdk from "../../../../sdk"
|
||||||
|
|
||||||
import validateJs from "validate.js"
|
import validateJs from "validate.js"
|
||||||
|
@ -125,7 +130,9 @@ export async function sqlOutputProcessing(
|
||||||
let finalRows: { [key: string]: Row } = {}
|
let finalRows: { [key: string]: Row } = {}
|
||||||
for (let row of rows as Row[]) {
|
for (let row of rows as Row[]) {
|
||||||
let rowId = row._id
|
let rowId = row._id
|
||||||
if (!rowId) {
|
if (opts?.sqs) {
|
||||||
|
rowId = getInternalRowId(row, table)
|
||||||
|
} else if (!rowId) {
|
||||||
rowId = generateIdForRow(row, table)
|
rowId = generateIdForRow(row, table)
|
||||||
row._id = rowId
|
row._id = rowId
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue