Skip to content
Source
Sign inSign up
TanStack/db

fix(query-db-collection): use deep equality for object field comparison #967

Mergedsamwillis(GitHub profile, opens in a new tab)merged 3 commits intomain fromrefs/pull/967/headmerged by samwillis(GitHub profile, opens in a new tab)

Showing 4 changed files with 11 additions and 26 deletions (loading 1).

x
0 of 4 viewed, 4 left
8 additions and 0 deletions.changeset/fix-object-field-update-rollback.mdAdded
View file
@@ -0,0 +1,8 @@
+---
+"@tanstack/query-db-collection": patch
+"@tanstack/db": patch
+---
+​
+fix(query-db-collection): use deep equality for object field comparison in query observer
+​
+Fixed an issue where updating object fields (non-primitives) with `refetch: false` in `onUpdate` handlers would cause the value to rollback to the previous state every other update. The query observer was using shallow equality (`===`) to compare items, which compares object properties by reference rather than by value. This caused the observer to incorrectly detect differences and write stale data back to syncedData. Now uses `deepEquals` for proper value comparison.
1 addition and 0 deletionspackages/db/src/index.tsModified
View file
@@ -13,6 +13,7 @@
export * from "./local-only"
export * from "./local-storage"
export * from "./errors"
+export { deepEquals } from "./utils"
export * from "./paced-mutations"
export * from "./strategies/index.js"
​
2 additions and 26 deletionspackages/query-db-collection/src/query.tsModified
View file
@@ -1,4 +1,5 @@