Fixing an issue where many rows were handled from different tables in client.
This commit is contained in:
parent
2dd1e7f45e
commit
42fb0584a2
|
@ -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) {
|
||||||
|
// map of tables, incase a row being loaded is not from the same table
|
||||||
|
const tables = {}
|
||||||
|
for (let row of rows) {
|
||||||
|
// fallback to passed in tableId if row doesn't have it specified
|
||||||
|
let rowTableId = row.tableId || tableId
|
||||||
|
let table = tables[rowTableId]
|
||||||
|
if (!table) {
|
||||||
// Fetch table schema so we can check column types
|
// Fetch table schema so we can check column types
|
||||||
const tableDefinition = await fetchTableDefinition(tableId)
|
table = await fetchTableDefinition(rowTableId)
|
||||||
const schema = tableDefinition && tableDefinition.schema
|
tables[rowTableId] = table
|
||||||
|
}
|
||||||
|
const schema = table?.schema
|
||||||
if (schema) {
|
if (schema) {
|
||||||
const keys = Object.keys(schema)
|
const keys = Object.keys(schema)
|
||||||
rows.forEach(row => {
|
|
||||||
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