From 527ac5450bef7a7af2b2e09e186aa7912bfb1472 Mon Sep 17 00:00:00 2001 From: David Fahlander Date: Fri, 15 Nov 2024 16:52:28 +0100 Subject: [PATCH] Bugfix: Resolution for #1946 was incorrect. This commit should solve it for good. (#2096) Co-authored-by: David Fahlander --- src/live-query/observability-middleware.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/live-query/observability-middleware.ts b/src/live-query/observability-middleware.ts index 0b2ef6a31..eabb5caf2 100644 --- a/src/live-query/observability-middleware.ts +++ b/src/live-query/observability-middleware.ts @@ -136,7 +136,9 @@ export const observabilityMiddleware: Middleware = { // Find the position of the primary key in the index: const pkPos = (idx.keyPath as string[]).findIndex(prop => prop === primaryKey.keyPath); // Update idxVals with the resulting primary keys to complete the index value: - res.results!.forEach(pk => idxVals[pkPos] = pk); + for (let i = 0, len = res.results!.length; i < len; ++i) { + idxVals[i][pkPos] = res.results![i]; + } // Add the updated index to the rangeset: getRangeSet(idx.name).addKeys(idxVals); });