Skip to content
Source
Sign inSign up
TanStack/db

fix(db-sqlite-persistence-core): rows marked with metadata prior to insert get reset causing stale data #1619

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

Showing 3 changed files with 92 additions and 3 deletions.

x
0 of 3 viewed, 3 left
5 additions and 0 deletions.changeset/small-tables-listen.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/db-sqlite-persistence-core': patch
+---
+​
+Fixed bug where internal metadata would get reset on insert causing stale items to remain
15 additions and 3 deletionspackages/db-sqlite-persistence-core/src/persisted.tsModified
View file
@@ -2290,9 +2290,21 @@
message.type === `insert` &&
normalization.operation.metadata === undefined
- openTransaction.rowMetadataWrites.set(normalization.operation.key, {
- type: `delete`,
- })
+ // Reset stale metadata for a fresh insert, but don't clobber an
+ // explicit metadata write already queued for this key in the same
+ // transaction (e.g. query reconcile stamps owners, then inserts).
+ if (
+ !openTransaction.rowMetadataWrites.has(
+ normalization.operation.key,
+ )
+ ) {
+ openTransaction.rowMetadataWrites.set(
+ normalization.operation.key,