Skip to content
Source
Sign inSign up
TanStack/db

Fix #1685 #1686

ClosedJaime02(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/1686/headopened

Showing 2 changed files with 142 additions and 2 deletions.

x
0 of 2 viewed, 2 left
25 additions and 2 deletionspackages/db/src/query/live/collection-config-builder.tsModified
View file
@@ -1864,6 +1864,9 @@
* 3. Drain nested buffers — route buffered grandchild changes to per-entry states
* 4. Flush per-entry states — recursively flush nested includes on each entry
* 5. Parent DELETEs — clean up child entries and routing index
+ *
+ * `routingCleanup` collects the rows whose internal routing stamp must be
+ * dropped once the whole recursive pass is done; the outermost call owns it.
function flushIncludesState(
includesState: Array<IncludesOutputState>,
@@ -1871,7 +1874,13 @@
parentId: string,
parentChanges: Map<unknown, Changes<any>> | null,
parentSyncMethods: SyncMethods<any> | null,
+ routingCleanup?: Set<Record<PropertyKey, any>>,
): void {
+ // The outermost call owns the cleanup set; nested calls inherit it so the
+ // stamp survives until every parent group has been flushed.
+ const isOutermostCall = routingCleanup === undefined
+ const cleanup = routingCleanup ?? new Set<Record<PropertyKey, any>>()
+​
for (const state of includesState) {
// Phase 1: Parent INSERTs — ensure a child Collection exists for every parent
if (parentChanges) {