Skip to content

Commit

Permalink
Fix for Budibase#9749 - static formulas would sometimes attempt to up…
Browse files Browse the repository at this point in the history
…date the same row multiple times, filter down to just the unique row list which requires updating.
  • Loading branch information
mike12345567 committed Feb 20, 2023
1 parent ac29e5c commit 4972657
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/server/src/api/controllers/row/staticFormula.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 4972657

Please sign in to comment.