refactor(query-db-collection): extract query ownership helpers#1664
Open
KyleAMathews wants to merge 2 commits into
Open
refactor(query-db-collection): extract query ownership helpers#1664KyleAMathews wants to merge 2 commits into
KyleAMathews wants to merge 2 commits into
Conversation
More templates
@tanstack/angular-db
@tanstack/browser-db-sqlite-persistence
@tanstack/capacitor-db-sqlite-persistence
@tanstack/cloudflare-durable-objects-db-sqlite-persistence
@tanstack/db
@tanstack/db-ivm
@tanstack/db-sqlite-persistence-core
@tanstack/electric-db-collection
@tanstack/electron-db-sqlite-persistence
@tanstack/expo-db-sqlite-persistence
@tanstack/node-db-sqlite-persistence
@tanstack/offline-transactions
@tanstack/powersync-db-collection
@tanstack/query-db-collection
@tanstack/react-db
@tanstack/react-native-db-sqlite-persistence
@tanstack/rxdb-db-collection
@tanstack/solid-db
@tanstack/svelte-db
@tanstack/tauri-db-sqlite-persistence
@tanstack/trailbase-db-collection
@tanstack/vue-db
commit: |
Contributor
📝 WalkthroughWalkthroughInternal query row ownership tracking is refactored into explicit helpers. Baseline hydration, placeholder cleanup, result reconciliation, and query cleanup now use these helpers without changing public APIs. ChangesQuery ownership lifecycle
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related issues
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Contributor
|
Size Change: 0 B Total Size: 125 kB ℹ️ View Unchanged
|
Contributor
|
Size Change: 0 B Total Size: 4.22 kB ℹ️ View Unchanged
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Extracts the internal row/query ownership bookkeeping in
@tanstack/query-db-collectioninto small private helpers. There is no intended public API or user-visible behavior change; this is lifecycle groundwork for future cancellation/lease-manager work.Related
Approach
This keeps the existing maps and lifecycle flow intact while centralizing the direct mutations of query ownership state:
addRowOwnerupdatesrowToQueriesandqueryToRowsfor one query/row relationship.addRowOwnershydrates ownership for persisted rows with multiple owners.removeRowOwnerremoves one query/row relationship while preserving existing empty-set behavior.removeQueryOwnershipcomputes the remaining owners for all rows associated with a query during cleanup.The extraction is intentionally local to
query.tsand does not change observer refcounting, invalidation handling, or persisted retention semantics.Key invariants
rowToQueriesandqueryToRowsremain inverse ownership indexes.Non-goals
Trade-offs
A full lease manager would make lifecycle ownership more explicit, but would be higher risk. This PR takes a smaller step: it reduces duplicated map mutation code and creates clearer seams for future work while preserving current behavior.
Verification
Files changed
packages/query-db-collection/src/query.ts— extracts private row/query ownership helpers and routes existing ownership call sites through them..changeset/extract-query-ownership-helpers.md— patch changeset for the internal refactor.Summary by CodeRabbit
Bug Fixes
Release
@tanstack/query-db-collection.