Skip to content
Source
Sign inSign up
TanStack/db

fix(db): materialize includes into parent rows before commit #1684

Closedjuliuslipp(GitHub profile, opens in a new tab)wants to merge 2 commits intomain fromrefs/pull/1684/headopened

Showing 3 changed files with 88 additions and 0 deletions.

x
0 of 3 viewed, 3 left
5 additions and 0 deletions.changeset/heavy-pandas-tell.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+"@tanstack/db": patch
+---
+​
+Materialize includes into parent rows before they commit so emitted change events already carry their included values. The includes flush ran only after the parent live query collection committed, patching stored rows in place without emitting; any consumer that copies rows at emit time — most commonly another live query layered on the collection, the shape framework adapters produce for component-level queries — captured the pre-patch row with its included fields unset. A parent-only update (no child changes) never triggered the follow-up re-emit, so those consumers kept empty includes until an unrelated child change recomputed the row. Fixes #1635.
36 additions and 0 deletionspackages/db/src/query/live/collection-config-builder.tsModified
View file
@@ -808,6 +808,7 @@
​
// 1. Flush parent changes
if (hasParentChanges) {
+ patchParentChangesFromIncludes(includesState, changesToApply)
begin()
changesToApply.forEach(this.applyChanges.bind(this, config))
commit()
@@ -1238,6 +1239,41 @@
return state.materialization !== `collection`
+/**
+ * Materializes the current includes state into freshly computed parent
+ * change values, so the change events emitted on commit already carry