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

View File

@ -6,11 +6,7 @@ import {
Row, Row,
Table, Table,
} from "@budibase/types" } from "@budibase/types"
import { processFormulas } from "../../../../utilities/rowProcessor" import { breakExternalTableId } from "../../../../integrations/utils"
import {
breakExternalTableId,
getPrimaryDisplay,
} from "../../../../integrations/utils"
import { basicProcessing } from "./basic" import { basicProcessing } from "./basic"
import { generateJunctionTableID } from "../../../../db/utils" import { generateJunctionTableID } from "../../../../db/utils"
@ -22,40 +18,6 @@ export function isManyToMany(
return !!(field as ManyToManyRelationshipFieldMetadata).through 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 * 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 * 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 continue
} }
const thisRow = fixArrayTypes( const thisRow = fixArrayTypes(
await basicProcessing({ basicProcessing({
row, row,
table, table,
isLinked: false, isLinked: false,

View File

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