Merge pull request #10895 from Budibase/fix/budi-7099
MySQL cyclic JSON conversion issue with primary display columns
This commit is contained in:
commit
fdad2e6bf3
|
@ -19,6 +19,7 @@ import {
|
|||
breakRowIdField,
|
||||
convertRowId,
|
||||
generateRowIdField,
|
||||
getPrimaryDisplay,
|
||||
isRowId,
|
||||
isSQL,
|
||||
} from "../../../integrations/utils"
|
||||
|
@ -391,7 +392,10 @@ export class ExternalRequest {
|
|||
}
|
||||
}
|
||||
relatedRow = processFormulas(linkedTable, relatedRow)
|
||||
const relatedDisplay = display ? relatedRow[display] : undefined
|
||||
let relatedDisplay
|
||||
if (display) {
|
||||
relatedDisplay = getPrimaryDisplay(relatedRow[display])
|
||||
}
|
||||
row[relationship.column][key] = {
|
||||
primaryDisplay: relatedDisplay || "Invalid display column",
|
||||
_id: relatedRow._id,
|
||||
|
|
|
@ -328,3 +328,27 @@ export function finaliseExternalTables(
|
|||
.reduce((r, [k, v]) => ({ ...r, [k]: v }), {})
|
||||
return { tables: finalTables, errors }
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the provided input is an object, but specifically not a date type object.
|
||||
* Used during coercion of types and relationship handling, dates are considered valid
|
||||
* and can be used as a display field, but objects and arrays cannot.
|
||||
* @param testValue an unknown type which this function will attempt to extract
|
||||
* a valid primary display string from.
|
||||
*/
|
||||
export function getPrimaryDisplay(testValue: unknown): string | undefined {
|
||||
if (testValue instanceof Date) {
|
||||
return testValue.toISOString()
|
||||
}
|
||||
if (
|
||||
Array.isArray(testValue) &&
|
||||
testValue[0] &&
|
||||
typeof testValue[0] !== "object"
|
||||
) {
|
||||
return testValue.join(", ")
|
||||
}
|
||||
if (typeof testValue === "object") {
|
||||
return undefined
|
||||
}
|
||||
return testValue as string
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue