Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
a6445a7
test(db): cover draft reverts, clone key classes, and deepEquals orde…
Oct 1, 2026
639ed5a
test(db): let Map values in the draft revert oracle be nested Sets
Oct 1, 2026
6b68b8d
refactor(db): simplify the draft proxy and share its equality walker
Oct 1, 2026
affd9f3
docs: record the draft proxy review
Oct 1, 2026
cccaf1b
fix(db): return functions stored in a draft as stored
Oct 1, 2026
721a509
docs: record the stored-function fix in the draft proxy review
Oct 1, 2026
1a07cd3
Apply code simplification and review fixes
Oct 1, 2026
0be15b3
docs: tie the draft proxy review to the review fixes
Oct 1, 2026
fcc353d
fix(db): clear reverted nested changes from the parent draft
Oct 1, 2026
36030ef
fix(db): clone typed-array subclasses and compare typed elements like…
Oct 1, 2026
967a28c
perf(db): iterate draft arrays without a Proxy read per element
Oct 1, 2026
5b4049c
perf(db): skip the draft entry list when deepEquals compares Maps
Oct 1, 2026
b57d600
fix(db): return drafts from array read methods on a draft
Oct 1, 2026
38d8ba7
fix(db): define a draft property with its value in one step
Oct 1, 2026
815432e
fix(db): compare objects within their class and keyless instances by …
Oct 1, 2026
a49ae90
test(db): pin that a detached stored method has no this
Oct 1, 2026
251f97c
docs: record the draft proxy fixes from the second review
Oct 1, 2026
1e2044b
refactor(db): drop draft code that only bought speed
Oct 1, 2026
674f87b
docs: record the draft proxy code-weight pass
Oct 1, 2026
b825e64
fix(db): keep a read-only non-configurable draft property as defined
Oct 1, 2026
bb48e2b
Merge origin/main into code-weight/draft-proxy
Oct 1, 2026
40262af
docs: record the defineProperty follow-up fix
Oct 1, 2026
0ce101a
fix(db): track accessor definitions and typed-array mutators in drafts
Oct 1, 2026
ca0a217
docs: record the accessor and typed-array mutator fixes
Oct 1, 2026
7e5dfee
fix(db): keep draft write-backs, frozen-key writes, and subarray read…
Oct 1, 2026
fe67162
docs: record the fixes from code review of the earlier fixes
Oct 1, 2026
cbd2aff
fix(db): return the draft from array mutators that return the array
Oct 1, 2026
556cbd8
test(db): close oracle gaps found by the loss audit
Oct 1, 2026
c049bf7
docs: record the loss-audit fixes and all ORC requirements
Oct 1, 2026
e5c806c
Merge origin/main into code-weight/draft-proxy
Oct 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .changeset/simplify-draft-proxy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
'@tanstack/db': patch
---

Simplify the mutation draft proxy and share one equality walker with `deepEquals`. A typical app bundle is about 350 B smaller with gzip.

This change also fixes draft writes that were lost or wrong:

- A function stored in a row is now returned as stored when read from a draft. Before, the draft returned a bound copy, so `draft.handler === handler` was false. A stored method also saw a private copy as `this`, so `collection.update` dropped the writes it made through `this`.
- Array methods such as `at`, `slice`, `concat`, `flat`, `toReversed`, and `with` now return drafts, so a write through their result is saved. `indexOf` and `includes` find an element that the draft returned, and `draft.items.constructor === Array` is true.
- `Object.defineProperty(draft, key, { value })` no longer throws when the descriptor does not set `writable` or `configurable`. Defining a getter on a draft is now a change.
- `fill`, `set`, `sort`, `reverse`, and `copyWithin` on a typed array in a draft, and writes through its `subarray`, are now saved. `sort`, `reverse`, `fill`, and `copyWithin` on a draft now return the draft, as the native methods return the array itself.
- Deleting a nested key that the callback added, or writing a nested value back, no longer leaves the parent marked as changed.
- A typed-array subclass whose constructor does not forward its argument is now copied with its elements. Typed arrays that hold `NaN` now equal themselves.

`deepEquals` and draft change detection also have new rules:

- Instances of two different classes are not equal. A plain or null-prototype object compares by keys with any class.
- A class instance without enumerable keys, such as a `File` or an object whose state is in private fields, equals only itself. Before, two such instances were always equal, so a draft dropped a write that replaced one.
- URLs compare by `href`.
- In draft change detection only, a typed array of another class is a change.
4 changes: 2 additions & 2 deletions docs/contributing/oracle-coverage.md

Large diffs are not rendered by default.

595 changes: 595 additions & 0 deletions docs/contributing/oracle-reviews/code-weight-draft-proxy.md

Large diffs are not rendered by default.

Loading
Loading