Summary#
When two sibling includes in .select() use the same alias (e.g., { i: issues } and { i: tags }), nested child collections silently produce empty results. The root cause is that all includes aliases are flattened into a single namespace — sharing one D2 graph input and one subscription, so the second sibling's collection data overwrites the first.
Fix#
Give each includes subquery its own independent D2 graph input:
extractCollectionAliases no longer traverses into IncludesSubquery nodes, keeping collectionByAlias scoped to the top-level query
compileQuery accepts a createInput factory; when processing includes, each child gets fresh inputs for its source aliases
compileBasePipeline merges the new inputs into inputsCache and compiledAliasToCollectionId under unique keys (__inc_N_alias), so each gets its own subscription feeding the correct collection
Test#
Regression test added to includes.test.ts: sibling includes with duplicate alias "i" — nested comments are populated. Fails without fix, passes with fix.
Fixes #1454
Thanks for isolating the duplicate sibling-alias failure. https://github.com/TanStack/db/pull/1740 (https://github.com/TanStack/db/commit/5d9335d0d42c1cc1ec2b92be8ce40ae8abe42827) replaced alias-keyed include materialization with opaque source identities; the current alpha-renaming oracle and nested Collection-valued reproduction pass. Closing this conflicting draft as superseded. The original fixture remains valuable regression coverage.