fix(solid-db): support findOne in useLiveQuery#1403
Merged
Conversation
More templates
@tanstack/angular-db
@tanstack/db
@tanstack/db-browser-wa-sqlite-persisted-collection
@tanstack/db-capacitor-sqlite-persisted-collection
@tanstack/db-cloudflare-do-sqlite-persisted-collection
@tanstack/db-electron-sqlite-persisted-collection
@tanstack/db-expo-sqlite-persisted-collection
@tanstack/db-ivm
@tanstack/db-node-sqlite-persisted-collection
@tanstack/db-react-native-sqlite-persisted-collection
@tanstack/db-sqlite-persisted-collection-core
@tanstack/db-tauri-sqlite-persisted-collection
@tanstack/electric-db-collection
@tanstack/offline-transactions
@tanstack/powersync-db-collection
@tanstack/query-db-collection
@tanstack/react-db
@tanstack/rxdb-db-collection
@tanstack/solid-db
@tanstack/svelte-db
@tanstack/trailbase-db-collection
@tanstack/vue-db
commit: |
Update type overloads to use InferResultType<TContext> so findOne queries return T | undefined instead of Array<T>. Add SingleResult/NonSingleResult overloads for pre-created collections. Check config.singleResult at runtime to return the first element instead of the full array. Fixes #1399 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
|
Size Change: 0 B Total Size: 111 kB ℹ️ View Unchanged
|
Contributor
|
Size Change: 0 B Total Size: 4.23 kB ℹ️ View Unchanged
|
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
useLiveQueryin@tanstack/solid-dbdid not support.findOne()— it always returned an array instead of a single object orundefined. This is the same bug previously fixed in react-db (#749), vue-db (#1134), and angular-db (#1261).InferResultType<TContext>sofindOne()queries returnT | undefinedinstead ofArray<T>SingleResult/NonSingleResultoverloads for pre-created collections passed viaAccessorconfig.singleResultat runtime to return the first element instead of the full arrayFixes #1399
Test plan
cd packages/solid-db && pnpm test— all 38 tests passT | undefined, non-findOne returnsArray<T>, pre-created collection with findOne🤖 Generated with Claude Code