Repository navigation
Translate ToString() on string expressions - #4047
Merged
Merged
Conversation
Match SQL Server and SQLite by returning string-mapped instances unchanged. Add focused predicate and grouping coverage and SQL assertions for the upstream string projection test. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 839e4245-5519-4593-84c7-2dfb4c10b82a
There was a problem hiding this comment.
🟢 Approval recommended
The localized change has targeted regression coverage and no identified blocking issues; tests were not executed.
No open issues 🎉
What changed in this PR
Fixes #4046 by translating ToString() on string-mapped expressions as the original SQL expression, preserving nulls without adding casts.
Changes:
- Adds string passthrough handling to the object-to-string translator.
- Covers predicates, null propagation, and object-typed grouping keys.
- Adds inherited projection SQL assertions across three query suites.
| File | Description |
|---|---|
| test/EFCore.PG.FunctionalTests/Query/Translations/StringTranslationsNpgsqlTest.cs | Adds focused translation regression tests. |
| test/EFCore.PG.FunctionalTests/Query/Inheritance/TPTGearsOfWarQueryNpgsqlTest.cs | Asserts string projection SQL for TPT. |
| test/EFCore.PG.FunctionalTests/Query/Inheritance/TPCGearsOfWarQueryNpgsqlTest.cs | Asserts string projection SQL for TPC. |
| test/EFCore.PG.FunctionalTests/Query/GearsOfWarQueryNpgsqlTest.cs | Asserts string projection SQL. |
| src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlObjectToStringTranslator.cs | Returns string-mapped expressions unchanged. |
Review effort: Balanced
This was referenced Oct 20, 2026
roji
added a commit
that referenced
this pull request
Oct 20, 2026
Backport #4047, adapting focused regressions to the existing Northwind functions suite. Retain inherited GearsOfWar, TPC and TPT projection SQL assertions. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 8445f728-0ea4-4167-ac34-f40a4d7e9657
roji
added a commit
that referenced
this pull request
Oct 20, 2026
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.
Return string-mapped instances unchanged in
NpgsqlObjectToStringTranslator, matching SQL Server and SQLite rather than adding a cast or coalescing nulls to an empty string.Add focused regression coverage for string predicates, null propagation, and object-typed string grouping keys used in
OrderByandWhere. Align with upstream coverage by adding SQL assertions for the inheritedToString_string_property_projectiontest in the GearsOfWar, TPC, and TPT suites.Fixes #4046.
Related to dotnet/efcore#20839, implemented upstream in dotnet/efcore#29349.