Fix alias cloning for json recordset table-valued functions#3773
Merged
roji merged 1 commit intonpgsql:mainfrom Mar 23, 2026
Merged
Fix alias cloning for json recordset table-valued functions#3773roji merged 1 commit intonpgsql:mainfrom
roji merged 1 commit intonpgsql:mainfrom
Conversation
7645re
commented
Mar 10, 2026
test/EFCore.PG.FunctionalTests/Query/AdHocJsonQueryNpgsqlTest.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Fixes alias handling when cloning PostgreSQL table-valued function (TVF) expressions used for JSON json[b]_to_recordset, preventing invalid SQL aliases that can surface as runtime failures (e.g. missing FROM-clause entries).
Changes:
- Adjust
PgTableValuedFunctionExpression.Clone(...)to preserve the original alias when there is no explicit column list, and to apply the cloned alias when explicit output columns exist. - Add a functional regression test covering a
GroupByover a JSON-collection predicate with projection of ordered group elements.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/EFCore.PG/Query/Expressions/Internal/PgTableValuedFunctionExpression.cs |
Fixes alias cloning behavior for JSON recordset TVFs to keep FROM references consistent. |
test/EFCore.PG.FunctionalTests/Query/AdHocJsonQueryNpgsqlTest.cs |
Adds a regression scenario exercising JSON collection predicates combined with grouping and element projection. |
You can also share your feedback on Copilot code review. Take the survey.
test/EFCore.PG.FunctionalTests/Query/AdHocJsonQueryNpgsqlTest.cs
Outdated
Show resolved
Hide resolved
src/EFCore.PG/Query/Expressions/Internal/PgTableValuedFunctionExpression.cs
Show resolved
Hide resolved
roji
requested changes
Mar 10, 2026
9d7137e to
82ffa7e
Compare
Contributor
Author
|
@roji everything seems to be done, are there any suggestions? |
roji
approved these changes
Mar 23, 2026
Member
roji
left a comment
There was a problem hiding this comment.
Thanks, LGTM! Thanks for your contribution! I'll go ahead and backport this to 10.0.x as well.
roji
pushed a commit
that referenced
this pull request
Mar 23, 2026
Member
|
Backported to 10.0.2 via 12a1aa8 |
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.
Fix alias cloning for
json[b]_to_recordsetinPgTableValuedFunctionExpression.Clone(...).For TVFs without
ColumnInfossuch asunnest, the originalalias must be preserved. For
jsonb_to_recordset, outputcolumns are explicitly named, so the cloned alias must be
applied instead.
This could previously cause execution-time failures such as
missing FROM-clause entry for table "o0".Adds a regression test covering GroupBy over a query filtered
by a JSON collection predicate and projecting ordered group
elements.
Fixes #3790