Repository navigation
Keep the id in an include's temp table when the queried document has duplicated fields (#5650) - #5651
Merged
jeremydmiller merged 2 commits intoOct 13, 2026
Conversation
…om a query session When the queried document has a duplicated field, the include's temp table is built from the duplicated-field select clause, which a query session builds without the id column. The include's join then reads d.id from that temp table and Postgres answers 42703 "column d.id does not exist". Every other session kind, and a query session on a document without duplicated fields, carries the id and passes. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…duplicated fields TemporaryTableStatement already swaps a query session's select clause for one that carries the id, "just in case" something downstream needs it. A document with duplicated fields reaches it through DuplicatedFieldSelectClause instead, which that check did not recognise, so the id was dropped and an include joined on the queried document's id failed with 42703. Ensure the id column on that clause too, the same way LINQ joins already ensure their key column (EnsureJoinKeyInCte). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Member
|
Merged, thanks @Blackclaws — nice minimal fix, and the theory over all four session kinds made the A/B easy to verify (1/8 red on master, 8/8 green with the fix). While reviewing I probed the adjacent shapes. If you want to pick that one up too, |
This was referenced Oct 14, 2026
Open
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.
Fixes #5650.
An
Include()joined on the queried document's own id failed with42703: column d.id does not existin a query session whenever the queried document had a duplicated field. The include's temp table was built from theDuplicatedFieldSelectClause, which a query session builds without the id column.Change
TemporaryTableStatementalready swaps a query session's select clause for one that carries the id. It now does the equivalent for aDuplicatedFieldSelectClause, callingEnsureColumn("d.id"). That's the same mechanism LINQ joins already use for their key column (EnsureJoinKeyInCte). In the other session kinds the id is already selected, so the call does nothing.Commits
LinqTests/Includes/include_on_the_queried_document_id.csis a theory over query, lightweight, identity-map and dirty-tracked sessions, each with and without a duplicated field on the queried document. Before the fix, only query + duplicated failed.TemporaryTableStatement.Testing
Run locally on net10.0 against PostgreSQL:
LinqTests: 1617 passed, 0 failed;CompiledQueryTests: 9 passed.No public API changes.