Skip to content

[10.0] Fix Last() on primitive collections returning the first array element - #3956

Merged
roji merged 1 commit into
hotfix/10.0.4from
roji-primitive-collection-last-10-backport
Oct 14, 2026
Merged

roji merged 1 commit into
hotfix/10.0.4from
roji-primitive-collection-last-10-backport

Conversation

@roji

@roji roji commented Oct 14, 2026

Copy link
Copy Markdown
Member

Summary

Backport #3925 (reviewed commit 32c2baac5209aaebade01d5ef287db3d9fb0a2fa) to hotfix/10.0.4 for #3909.

  • Preserve descending ordinality and WITH ORDINALITY for Last() / LastOrDefault(); ascending cleanup and First() SQL remain unchanged.
  • Copy later retained tables into the lazily allocated replacement table array.
  • Add the source PR's two Last() / LastOrDefault() regression tests without other behavior changes.

Validation

  • dotnet build test/EFCore.PG.FunctionalTests: succeeded with no warnings or errors on .NET SDK 10.0.300 / EF Core 10.0.4.
  • 20 selected functional tests passed against local PostgreSQL 18.4 using Test__Npgsql__DefaultConnection='Host=localhost': both new regressions, First/FirstOrDefault, Single/SingleOrDefault, joins, SelectMany, Skip/Take, descending ElementAt, and inherited-test override coverage.
  • The shared test store was used in an exclusive coordinated slot; no fixture/database-name changes are included.

Backport #3925 to hotfix/10.0.4, preserving descending ordinality for Last/LastOrDefault and retaining later tables during unnest cleanup.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 655047e3-ebb2-4a2e-9817-c998f679450e
@roji
roji merged commit 70acb2a into hotfix/10.0.4 Oct 14, 2026
11 checks passed
@roji
roji deleted the roji-primitive-collection-last-10-backport branch October 14, 2026 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Last()/LastOrDefault() on primitive collections is translated like First() — missing descending ordinality ordering

1 participant