Fix select() to handle direct ref returns as spreads#1276
Open
KyleAMathews wants to merge 2 commits intomainfrom
Open
Fix select() to handle direct ref returns as spreads#1276KyleAMathews wants to merge 2 commits intomainfrom
KyleAMathews wants to merge 2 commits intomainfrom
Conversation
… operator
When a RefProxy is returned directly from the select callback
(e.g. `.select(({ users }) => users)`), convert it to a spread sentinel
so it behaves identically to the spread form
(`.select(({ users }) => ({ ...users }))`).
Previously, the direct return form would pass a RefProxy through
buildNestedSelect → toExpr, producing a PropRef whose own properties
(type, path) were iterated by the compiler instead of the actual row
data — yielding ref metadata objects instead of the real data.
The fix detects RefProxy at the top level of select() and synthesizes
the equivalent spread sentinel before handing off to buildNestedSelect.
https://claude.ai/code/session_01KAGFqbqFxY2YYV4uTVTBa8
|
More templates
@tanstack/angular-db
@tanstack/db
@tanstack/db-ivm
@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: |
Contributor
|
Size Change: +54 B (+0.06%) Total Size: 92.1 kB
ℹ️ View Unchanged
|
Contributor
|
Size Change: 0 B Total Size: 3.7 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.
🎯 Changes
Fixed a common pitfall in the
select()query builder where returning a ref directly (e.g.,select(({ users }) => users)) would produce ref/proxy metadata instead of actual row data.The fix detects when a callback returns a
RefProxydirectly and automatically treats it as if the user had spread it (e.g.,select(({ users }) => ({ ...users }))). This is accomplished by:isRefProxy()check in theselect()methodbuildNestedSelect()logic already handles correctly✅ Checklist
pnpm test.🚀 Release Impact
Test Coverage: Added three comprehensive test cases covering:
https://claude.ai/code/session_01KAGFqbqFxY2YYV4uTVTBa8