Fixing an issue where many rows were handled from different tables in client.
This commit is contained in:
parent
3f960e4f13
commit
a864c511c4
|
@ -112,13 +112,21 @@ export const enrichRows = async (rows, tableId) => {
|
||||||
if (!Array.isArray(rows)) {
|
if (!Array.isArray(rows)) {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
if (rows.length && tableId) {
|
if (rows.length) {
|
||||||
// Fetch table schema so we can check column types
|
// map of tables, incase a row being loaded is not from the same table
|
||||||
const tableDefinition = await fetchTableDefinition(tableId)
|
const tables = {}
|
||||||
const schema = tableDefinition && tableDefinition.schema
|
for (let row of rows) {
|
||||||
if (schema) {
|
// fallback to passed in tableId if row doesn't have it specified
|
||||||
const keys = Object.keys(schema)
|
let rowTableId = row.tableId || tableId
|
||||||
rows.forEach(row => {
|
let table = tables[rowTableId]
|
||||||
|
if (!table) {
|
||||||
|
// Fetch table schema so we can check column types
|
||||||
|
table = await fetchTableDefinition(rowTableId)
|
||||||
|
tables[rowTableId] = table
|
||||||
|
}
|
||||||
|
const schema = table?.schema
|
||||||
|
if (schema) {
|
||||||
|
const keys = Object.keys(schema)
|
||||||
for (let key of keys) {
|
for (let key of keys) {
|
||||||
const type = schema[key].type
|
const type = schema[key].type
|
||||||
if (type === "link" && Array.isArray(row[key])) {
|
if (type === "link" && Array.isArray(row[key])) {
|
||||||
|
@ -137,7 +145,7 @@ export const enrichRows = async (rows, tableId) => {
|
||||||
row[`${key}_first`] = url
|
row[`${key}_first`] = url
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return rows
|
return rows
|
||||||
|
|
Loading…
Reference in New Issue