1
0
Fork 0
mirror of synced 2024-07-07 15:25:52 +12:00
This commit is contained in:
adrinr 2023-02-24 11:24:29 +01:00
parent 2fc97189e5
commit 045822d65e

View file

@ -154,11 +154,12 @@ function generateIdForRow(
// build id array // build id array
let idParts = [] let idParts = []
for (let field of primary) { for (let field of primary) {
// need to handle table name + field or just field, depending on if relationships used let fieldValue = extractFieldValue({
let fieldValue = row[`${table.name}.${field}`] row,
if (!fieldValue && !isLinked) { tableName: table.name,
fieldValue = row[field] fieldName: field,
} isLinked,
})
if (fieldValue) { if (fieldValue) {
idParts.push(fieldValue) idParts.push(fieldValue)
} }
@ -181,6 +182,25 @@ function getEndpoint(tableId: string | undefined, operation: string) {
} }
} }
// need to handle table name + field or just field, depending on if relationships used
function extractFieldValue({
row,
tableName,
fieldName,
isLinked,
}: {
row: Row
tableName: string
fieldName: string
isLinked: boolean
}) {
let value = row[`${tableName}.${fieldName}`]
if (value == null && !isLinked) {
value = row[fieldName]
}
return value
}
function basicProcessing({ function basicProcessing({
row, row,
table, table,
@ -195,8 +215,13 @@ function basicProcessing({
for (let field of Object.values(table.schema)) { for (let field of Object.values(table.schema)) {
const fieldName = field.name const fieldName = field.name
const pathValue = row[`${table.name}.${fieldName}`] const value = extractFieldValue({
const value = pathValue != null || isLinked ? pathValue : row[fieldName] row,
tableName: table.name,
fieldName,
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