Skip to content

Preserve independent Skip/Take parameters in precompiled queries - #39478

Open
AndriySvyryd with Copilot wants to merge 4 commits into
mainfrom
copilot/query-precompiler-aliases-skip-take
Open

AndriySvyryd with Copilot wants to merge 4 commits into
mainfrom
copilot/query-precompiler-aliases-skip-take

Conversation

Copilot AI commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Precompilation evaluates .Skip(skip).Take(take) with equal dummy values, causing parameter deduplication to alias LIMIT and OFFSET and return incorrect pages. Queries inside local functions can also fail to recognize captured paging variables.

  • Parameter identity: Bypass constant-expression deduplication during precompilation; preserve existing deduplication for runtime queries and captured-member expressions.
  • Local-function captures: Include Roslyn’s Captured symbols alongside DataFlowsIn when discovering query inputs.
  • Regression coverage: Assert paging results and distinct SQL parameters on SQLite and SQL Server, including async local-function captures.

Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix precompiler aliases for Skip and Take SQL parameters Preserve independent Skip/Take parameters in precompiled queries Oct 30, 2026
Copilot AI requested a review from AndriySvyryd October 30, 2026 22:39
@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 #39478.

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.

🟡 Changes recommended

A critical active finding remains: precompiled path calculation can still deduplicate equal Skip/Take parameters, causing the generated extractor to omit one parameter and mismatch the two-parameter SQL.

1 open issue
What changed in this PR

This pull request fixes incorrect pagination in precompiled queries by preserving independent Skip and Take parameters and recognizing captures from enclosing local functions.

Changes:

  • Prevents equal dummy constants from being deduplicated during precompilation.
  • Includes Roslyn Captured symbols when discovering query inputs.
  • Adds SQLite and SQL Server regression coverage and documents the relevant invariants.

This pull request requires changes.

File Summary
test/​EFCore.SqlServer.FunctionalTests/​Query/​PrecompiledQuerySqlServerTest.cs Adds SQL Server paging result and parameter assertions.
test/​EFCore.Sqlite.FunctionalTests/​Query/​PrecompiledQuerySqliteTest.cs Adds SQLite paging result and parameter assertions.
test/​EFCore.Relational.Specification.Tests/​Query/​PrecompiledQueryRelationalTestBase.cs Adds shared paging and local-function capture regressions.
src/​EFCore/​Query/​Internal/​ExpressionTreeFuncletizer.cs Adjusts parameter deduplication for precompiled queries; the current guard does not cover the path-calculation pass.
src/​EFCore.Design/​Query/​Internal/​CSharpToLinqTranslator.cs Includes enclosing local-function captures in query input discovery.
.agents/​skills/​query-pipeline/​SKILL.md Documents precompilation and local-capture requirements.

Review effort: Lite

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@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.

🔵 Needs a closer look

Human validation is needed for generated interceptors, runtime parameter binding across providers, and broader non-lambda/local-function capture shapes beyond the focused relational tests.

No open issues 🎉

1 resolved since last review

Review effort: Lite

Comment thread .agents/skills/query-pipeline/SKILL.md Resolved
Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
Copilot AI requested a review from AndriySvyryd October 30, 2026 23:31
@AndriySvyryd
AndriySvyryd marked this pull request as ready for review October 31, 2026 00:13
@AndriySvyryd
AndriySvyryd requested a review from a team as a code owner October 31, 2026 00:13
@AndriySvyryd
AndriySvyryd requested review from cincuranet and a lite review from Copilot and removed request for Copilot October 31, 2026 00:13
@github-code-quality

Copy link
Copy Markdown

Code coverage overview

Languages: C#

C# / code-coverage

main ed0b576 copilot/query-precom... c0b7c17 +/-
76% 76% 0%
View coverage of the 10 most impacted files.
File main ed0b576 copilot/query-precom... c0b7c17 +/-
src/Microsoft.D...qliteCommand.cs 95% 92% -3%
src/EFCore.Rela...CommandCache.cs 100% 98% -2%
src/Shared/NonC...yInitializer.cs 12% 11% -1%
src/EFCore/Quer...eFuncletizer.cs 87% 87% 0%
src/EFCore.Abst...erExtensions.cs 100% 100% 0%
src/EFCore.Desi...onExtensions.cs 100% 100% 0%
src/EFCore.Desi...CSharpHelper.cs 96% 96% 0%
src/EFCore.Desi...eportHandler.cs 47% 47% 0%
src/EFCore.Desi...mnExtensions.cs 100% 100% 0%
src/Microsoft.D...nnectionPool.cs 97% 100% +3%

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

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 aliases Skip and Take into a single SQL parameter

3 participants