-
Notifications
You must be signed in to change notification settings - Fork 202
Duplicate alias in sibling includes silently breaks nested children #1454
Copy link
Copy link
Open
Description
- I've validated the bug against the latest version of DB packages
Describe the bug
When two sibling includes in .select() use the same alias letter, nested child collections silently produce empty results. No error or warning is produced — data is silently lost.
For example, if an issues include uses { i: issues } and a sibling tags include uses { i: tags }, any nested grandchild inside issues (e.g., comments) returns empty. Changing the tags alias to { t: tags } fixes it.
Reproducible with this test in PR #1455.
Steps to Reproduce
const collection = createLiveQueryCollection((q) =>
q.from({ p: projects }).select(({ p }) => ({
id: p.id,
issues: q
.from({ i: issues }) // alias "i"
.where(({ i }) => eq(i.projectId, p.id))
.select(({ i }) => ({
id: i.id,
comments: q // nested grandchild
.from({ c: comments })
.where(({ c }) => eq(c.issueId, i.id))
.select(({ c }) => ({ id: c.id, body: c.body })),
})),
tags: q
.from({ i: tags }) // same alias "i" — breaks comments above
.where(({ i }) => eq(i.projectId, p.id))
.select(({ i }) => ({ id: i.id, label: i.label })),
})),
)
await collection.preload()
const alpha = collection.get(1)
const issue10 = alpha.issues.get(10)
issue10.comments // empty — should contain comments for issue 10Observed Behavior
tagsis populated correctlyissuescontains rows, but they come from the wrong collection (tags data routed to the issues pipeline)- Nested
commentsinside issues is always empty - No error or warning is thrown
Expected Behavior
Aliases in sibling includes should be independent scopes. Using the same alias letter in different sibling subqueries should just work — each gets its own data pipeline.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels