Repository navigation
Fix TODATETIMEOFFSET translation in projection - #39223
Open
Aziz-Dhiab wants to merge 6 commits into
Open
Aziz-Dhiab wants to merge 6 commits into
Aziz-Dhiab wants to merge 6 commits into
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The new index-based constant-conversion path lacks a regression test for the Guid materialization failure it is intended to prevent.
1 open finding
What changed in this PR
This PR enables relational constructor translation in projections, addressing the DateTimeOffset case in #38083 while preserving typed constant materialization.
Changes:
- Route eligible constructors through SQL projection translation and apply explicit conversion to supported constants in both binding paths.
- Add shared projection tests and provider-specific SQL assertions; update affected SQL Server baselines.
| File | Description |
|---|---|
| test/EFCore.SqlServer.FunctionalTests/Query/Translations/Temporal/DateTimeOffsetTranslationsSqlServerTest.cs | Asserts TODATETIMEOFFSET projection SQL. |
| test/EFCore.SqlServer.FunctionalTests/Query/TemporalGearsOfWarQuerySqlServerTest.cs | Asserts temporal date-constructor SQL. |
| test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSelectQuerySqlServerTest.cs | Updates constant-conversion SQL baselines. |
| test/EFCore.SqlServer.FunctionalTests/Query/Inheritance/TPTGearsOfWarQuerySqlServerTest.cs | Asserts TPT date-constructor SQL. |
| test/EFCore.SqlServer.FunctionalTests/Query/Inheritance/TPCGearsOfWarQuerySqlServerTest.cs | Asserts TPC date-constructor SQL. |
| test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs | Asserts date-constructor SQL. |
| test/EFCore.Sqlite.FunctionalTests/Query/Translations/Temporal/DateTimeOffsetTranslationsSqliteTest.cs | Asserts SQLite projection SQL. |
| test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarQuerySqliteTest.cs | Asserts SQLite date-constructor SQL. |
| test/EFCore.Specification.Tests/Query/Translations/Temporal/DateTimeOffsetTranslationsTestBase.cs | Adds a shared DateTimeOffset projection test. |
| test/EFCore.Specification.Tests/Query/GearsOfWarQueryTestBase.cs | Adds shared date-constructor projection coverage. |
| test/EFCore.Cosmos.FunctionalTests/Query/Translations/Temporal/DateTimeOffsetTranslationsCosmosTest.cs | Asserts Cosmos projection SQL. |
| src/EFCore.Relational/Query/Internal/RelationalProjectionBindingExpressionVisitor.cs | Changes constructor routing and constant conversion. |
🧠 Review effort: Lite
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 #38083
Support constructor translation in projection by routing any
NewExpressiontoTranslateProjectionin index-based binding, this is only done when theNewExpressionhas no parameters because without parameters, there's nothing to project.This change caused potentially translatable new expressions with constant parameters in projection to cause an
InvalidCastExceptionsimilar to #35826 so I added a similar fix for index-based bindingAdded tests to make sure the translation to TODATETIMEOFFSET is correct and tests for the
InvalidCastExceptionscenario