Repository navigation
fix: keep EF Core's _ord column an integer in the empty-root rewrite (10.x, #325) - #390
Merged
Merged
Conversation
…319) EF Core types the _ord ordering column of its empty query root like the elements, so TypeTheNulls cast it to the range type with them (NULL::int4range AS _ord). It is an integer when the list has elements, so a shape comparing it with one would fail on the server for the empty list only. Write it as 0, as OneRowOfNulls does on release/10.x. Found-By: RV Defect-Class: SQL Co-Authored-By: Claude Opus 5.5 <[email protected]> (cherry picked from commit 474fc44)
CaffeinatedCoder
enabled auto-merge
October 24, 2026 20:19
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.
Closes #325
This is the 10.x port of #319 for 10.2.0 (#358). It is
git cherry-pick -xof 474fc44 from PR #389.Problem
On EF Core 10.0.2 and later, EF Core replaces an empty captured list with its own
SELECT … WHERE FALSE(dotnet/efcore#37216).TypeTheNullsthen cast EF Core's_ordordering column to the range type, along with the element column:It is latent: no answer changed. But a shape comparing
_ordwith an integer would have failed on the server, and only for the empty list. On the EF Core 10.0.0 floor,OneRowOfNullsalready writes0.Change
EmptyCollectionRewriter.TypeTheNulls:_ordbecomes0, the same code change as onmain._ordsentence goes into the 10.0.2-and-later paragraph.EmptyCollectionSql.EfCoreReplacesTheEmptyValues: the floor'sVALUES (0, NULL::int4range), and the patch'sSELECT 0 AS _ord, NULL::int4range ….### Fixedrow under[10.2.0]in the root changelog and the EF Core package's changelog. The row says "on EF Core 10.0.2 and later".Tests
FirstOrDefault_OverAnEmptyCapturedList_KeepsTheOrderingColumnAnIntegerpasses on the floor (EF Core 10.0.0) and on-p:EfFloat=10.0.13 -p:NpgsqlEfFloat=10.0.3.actual: … SELECT NULL::int4range AS _ord …. On the floor it can't fail that way, because the floor never reachesTypeTheNulls.RangeCollectionContainsTests,SetCollectionContainsTestsandCapturedCollectionProbeTests(28 tests).Closes #325doesn't act onrelease/10.x, so the issue is closed by hand after the merge.🤖 Generated with Claude Code