Skip to content

Handle implicit numeric literal conversions in query precompilation - #39312

Merged
AndriySvyryd merged 4 commits into
mainfrom
copilot/fix-decimal-conversion-error
Nov 6, 2026
Merged

AndriySvyryd merged 4 commits into
mainfrom
copilot/fix-decimal-conversion-error

Conversation

Copilot AI commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Query precompilation rejects legal decimal projections such as group.Balance + (amount > 0 ? amount : 0): it passes a boxed integer literal with a decimal target type to Expression.Constant.

  • Translation: Convert numeric literal values to their semantic target type before constructing constants, preserving null and nonnumeric handling.
  • Coverage: Add implicit-zero and explicit-decimal control cases, widening/narrowing and character conversions, and projection generation with managed compilation on SQLite and SQL Server. Generated-query execution and NativeAOT publication remain outside this coverage.

Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix integer zero conversion issue in query precompiler Handle implicit numeric literal conversions in query precompilation Oct 17, 2026
Copilot AI requested a review from AndriySvyryd October 17, 2026 03:02
Comment thread .agents/skills/query-pipeline/SKILL.md Resolved
@AndriySvyryd
AndriySvyryd requested a balanced review from Copilot October 17, 2026 04:17
@github-actions

Copy link
Copy Markdown
Contributor

Agent harness evaluation deferred

This PR affects: query-pipeline. Automatic evaluation is deferred because this PR is currently marked as draft. Once it is ready for review, the usual author authorization rules apply. A contributor with write access can comment /eval or /eval component-name, or run the workflow manually for pull request #39312.

Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused conversion fix and regression coverage match the stated scope, with no identified blocking issues.

No open issues 🎉

What changed in this PR

Fixes #39303 by converting numeric literal values to their semantic target types before constructing query-precompilation constants.

Changes:

  • Handles implicit numeric conversions while preserving null and nonnumeric handling.
  • Adds translator regressions and decimal projection generation/managed-compilation coverage.
  • Documents validation without query execution or NativeAOT publication.
File Description
test/​EFCore.SqlServer.FunctionalTests/​Query/​AdHocPrecompiledQuerySqlServerTest.cs Adds the provider override with an empty SQL assertion.
test/​EFCore.Relational.Specification.Tests/​Query/​AdHocPrecompiledQueryRelationalTestBase.cs Adds the decimal projection compilation regression.
test/​EFCore.Design.Tests/​Query/​CSharpToLinqTranslatorTest.cs Covers decimal, character, widening, and narrowing conversions.
src/​EFCore.Design/​Query/​Internal/​CSharpToLinqTranslator.cs Converts numeric values before constructing typed constants.
.agents/​skills/​query-pipeline/​SKILL.md Documents generation-only validation boundaries.

Review effort: Balanced

@AndriySvyryd
AndriySvyryd marked this pull request as ready for review October 17, 2026 04:33
@AndriySvyryd
AndriySvyryd requested a review from a team as a code owner October 17, 2026 04:33
@AndriySvyryd
AndriySvyryd requested review from cincuranet and a balanced review from Copilot October 17, 2026 04:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

Static review identified no blocking defects in the localized fix or scoped regression coverage; tests were not run.

No open issues 🎉

Review effort: Balanced

@github-code-quality

github-code-quality Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Code coverage overview

Languages: C#

C# / code-coverage

main ed0b576 copilot/fix-decimal-... 25e712e +/-
76% 76% 0%
View coverage of the 10 most impacted files.
File main ed0b576 copilot/fix-decimal-... 25e712e +/-
src/Microsoft.D...qliteCommand.cs 95% 92% -3%
src/Shared/NonC...yInitializer.cs 12% 11% -1%
src/Shared/Shar...peExtensions.cs 23% 23% 0%
src/EFCore.Desi...nqTranslator.cs 84% 84% 0%
src/EFCore.Abst...erExtensions.cs 100% 100% 0%
src/EFCore.Cosm...nsExtensions.cs 82% 82% 0%
src/EFCore.Desi...onExtensions.cs 100% 100% 0%
src/EFCore.Desi...viderFactory.cs 95% 95% 0%
src/EFCore.Desi...CSharpHelper.cs 96% 96% 0%
src/EFCore.Desi...eportHandler.cs 47% 47% 0%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.


Updated October 31, 2026 00:16 UTC

Copilot AI balanced review requested due to automatic review settings October 30, 2026 23:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the numeric-literal conversion fix.

No open issues 🎉

Review effort: Balanced

@AndriySvyryd
AndriySvyryd merged commit 16f8a8b into main Nov 6, 2026
22 of 24 checks passed
@AndriySvyryd
AndriySvyryd deleted the copilot/fix-decimal-conversion-error branch November 6, 2026 23:41
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Nov 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Query precompiler rejects an integer zero implicitly converted to decimal in a projection

4 participants