Fix for #9749 - static formulas would sometimes attempt to update the same row multiple times, filter down to just the unique row list which requires updating.

This commit is contained in:
mike12345567 2023-02-20 15:35:14 +00:00
parent 53f6b2b6e6
commit 1eb2307fed
1 changed files with 7 additions and 1 deletions

View File

@ -38,7 +38,13 @@ export async function updateRelatedFormula(
if (!relatedRows[relatedTableId]) {
relatedRows[relatedTableId] = []
}
relatedRows[relatedTableId] = relatedRows[relatedTableId].concat(field)
// filter down to the rows which are not already included in related
const currentIds = relatedRows[relatedTableId].map(row => row._id)
const uniqueRelatedRows = field.filter(
(row: Row) => !currentIds.includes(row._id)
)
relatedRows[relatedTableId] =
relatedRows[relatedTableId].concat(uniqueRelatedRows)
}
}
for (let tableId of table.relatedFormula) {