Skip to content
Source
Sign inSign up
TanStack/db

fix(db): preserve mutation reconciliation semantics #1835

MergedKyleAMathews(GitHub profile, opens in a new tab)merged 5 commits intomain fromrefs/pull/1835/headmerged by KyleAMathews(GitHub profile, opens in a new tab)

Showing 10 changed files with 46 additions and 6 deletions (loading 7).

x
0 of 10 viewed, 10 left
5 additions and 0 deletions.changeset/fix-mutation-reconciliation.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/db': patch
+---
+​
+Fix same-key delete-then-insert reduction, preserve whole-row replacements through local adapters, and publish immutable previous values for live-object and replacement-object sync updates. Same-reference live rows still require an immutable provider `previousValue`; stale or partial values on that reused reference remain unsupported.
12 additions and 2 deletionspackages/db/src/collection/changes.tsModified
View file
@@ -124,7 +124,13 @@
// Skip batching for user actions (forceEmit=true) to keep UI responsive
if (this.shouldBatchEvents && !forceEmit) {
// Add events to the batch
- this.batchedEvents.push(...changes)
+ this.batchedEvents.push(
+ ...changes.map((change) =>
+ change.type === `delete`
+ ? this.enrichChangeWithVirtualProps(change)
+ : change,
+ ),
+ )
return
​
@@ -146,7 +152,11 @@