Fixing test case, external rows formulas were being executed twice which lead to different error messages.

This commit is contained in:
mike12345567 2024-04-08 15:28:15 +01:00
parent fbcc4b83a1
commit 70fac58e32
4 changed files with 13 additions and 55 deletions

View File

@ -50,7 +50,7 @@ export function generateIdForRow(
return generateRowIdField(idParts)
}
export async function basicProcessing({
export function basicProcessing({
row,
table,
isLinked,
@ -60,21 +60,17 @@ export async function basicProcessing({
table: Table
isLinked: boolean
internal?: boolean
}): Promise<Row> {
let thisRow: Row = {}
}): Row {
const thisRow: Row = {}
// filter the row down to what is actually the row (not joined)
let toIterate = Object.keys(table.schema)
if (internal) {
toIterate = toIterate.concat(CONSTANT_INTERNAL_ROW_COLS)
}
for (let fieldName of toIterate) {
for (let field of Object.values(table.schema)) {
const fieldName = field.name
const value = extractFieldValue({
row,
tableName: internal ? table._id! : table.name,
tableName: table.name,
fieldName,
isLinked,
})
// all responses include "select col as table.col" so that overlaps are handled
if (value != null) {
thisRow[fieldName] = value
@ -85,7 +81,7 @@ export async function basicProcessing({
thisRow.tableId = table._id
thisRow._rev = "rev"
}
return processFormulas(table, thisRow)
return thisRow
}
export function fixArrayTypes(row: Row, table: Table) {

View File

@ -6,11 +6,7 @@ import {
Row,
Table,
} from "@budibase/types"
import { processFormulas } from "../../../../utilities/rowProcessor"
import {
breakExternalTableId,
getPrimaryDisplay,
} from "../../../../integrations/utils"
import { breakExternalTableId } from "../../../../integrations/utils"
import { basicProcessing } from "./basic"
import { generateJunctionTableID } from "../../../../db/utils"
@ -22,40 +18,6 @@ export function isManyToMany(
return !!(field as ManyToManyRelationshipFieldMetadata).through
}
export function squashRelationshipColumns(
table: Table,
tables: TableMap,
row: Row,
relationships: RelationshipsJson[]
): Row {
for (let relationship of relationships) {
const linkedTable = tables[relationship.tableName]
if (!linkedTable || !row[relationship.column]) {
continue
}
const display = linkedTable.primaryDisplay
for (let key of Object.keys(row[relationship.column])) {
let relatedRow: Row = row[relationship.column][key]
// add this row as context for the relationship
for (let col of Object.values(linkedTable.schema)) {
if (col.type === FieldType.LINK && col.tableId === table._id) {
relatedRow[col.name] = [row]
}
}
relatedRow = processFormulas(linkedTable, relatedRow)
let relatedDisplay
if (display) {
relatedDisplay = getPrimaryDisplay(relatedRow[display])
}
row[relationship.column][key] = {
primaryDisplay: relatedDisplay || "Invalid display column",
_id: relatedRow._id,
}
}
}
return row
}
/**
* This iterates through the returned rows and works out what elements of the rows
* actually match up to another row (based on primary keys) - this is pretty specific

View File

@ -142,7 +142,7 @@ export async function sqlOutputProcessing(
continue
}
const thisRow = fixArrayTypes(
await basicProcessing({
basicProcessing({
row,
table,
isLinked: false,

View File

@ -18063,10 +18063,10 @@ postgres-interval@^1.1.0:
dependencies:
xtend "^4.0.0"
posthog-js@^1.116.6:
version "1.117.0"
resolved "https://registry.yarnpkg.com/posthog-js/-/posthog-js-1.117.0.tgz#59c3e520f6269f76ea82dce8760fbc33cdd7f48f"
integrity sha512-+I8q5G9YG6r6wOLKPT+C+AV7MRhyVFJMTJS7dfwLmmT+mkVxQ5bfC59hBkJUObOR+YRn5jn2JT/sgIslU94EZg==
posthog-js@^1.118.0:
version "1.120.0"
resolved "https://registry.yarnpkg.com/posthog-js/-/posthog-js-1.120.0.tgz#43a364a930d200e14ddf217ed340e5085fb8afcd"
integrity sha512-A1FOJabDjt0mFg2ePfgqeZPUQl8WY6L+fNNfN/89gqvPoI7HmHta2hY/9tDQ+mBRHjj4nah5KK/EWqJHq69fGw==
dependencies:
fflate "^0.4.8"
preact "^10.19.3"