Repository navigation
docs: ordering by a bound puts the rows without it where PostgreSQL puts NULLs - #372
Merged
Merged
Conversation
…uts NULLs (#359) docs/ranges.md#sort-ranges documents PostgreSQL's NULLS LAST against memory's null-first for a nullable column, but not for an ordering by a bound, where the NULLs come from non-null ranges and so appear on a required column too, and the README, the EF Core README, docs/efcore.md and getting-started.md all show OrderBy(b => b.Period.LowerBound()) as their ordering example. docs/efcore.md gets a Good to know bullet with the placement (last ascending, first descending) and the two ways to sort otherwise: a Bound() != null key in front gives memory's order, ordering by the range gives the range order. The ranges.md bullet and the four examples point there. Claim E72. ExecutedQueryTests.OrderingByABound_PutsTheRowsWithoutItWherePostgresPutsNulls orders a range and a multirange column of every shape by each bound in both directions and asserts the documented placement and the keyed order. The seed bound-declared-null-only-for-a-null-argument.patch (#349 reverted) is caught by it and by the bound sweep. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 24, 2026
CaffeinatedCoder
enabled auto-merge
October 24, 2026 16:34
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 #359
Problem
docs/ranges.md#sort-rangesdocuments a deliberate difference: PostgreSQL putsNULLlast in an ascendingORDER BY, and memory putsnullfirst. It says that for a nullable column only. An ordering byLowerBound()orUpperBound()meets the same difference on any column, because the bound of an empty or unbounded range is NULL. A grid sorted by "from" therefore shows open-start and empty rows at the bottom when it sorts in the database, and at the top when it sorts in memory. Four examples show exactly that ordering with no word about it: the README, the EF Core package README,docs/efcore.mdanddocs/getting-started.md, where the result is calledchronological.Change
Docs only. The behaviour follows the documented decision; no translation changes.
docs/efcore.md#read-bounds-merge-ranges-and-aggregate: a "Good to know" bullet. It gives the placement: the empty rows and the rows without that bound sort last ascending and first descending, also on a required column. It also gives two ways to sort otherwise: a!= nullkey in front (OrderBy(b => b.Period.LowerBound() != null).ThenBy(b => b.Period.LowerBound())) gives memory's order, andOrderBy(b => b.Period)gives the range order, where open starts come first. Claim E72 quotes it.docs/ranges.md#sort-ranges: the NULL bullet says the same holds for an ordering by a bound, and links there.Docs:line under### Fixedin[11.0.0-preview.1]. The EF Core changelog gets that section here. The 10.x side is 10.x: docs: ordering by LowerBound() or UpperBound() puts open-ended and empty rows where PostgreSQL puts NULLs (port of #359) #364.Tests
ExecutedQueryTests.OrderingByABound_PutsTheRowsWithoutItWherePostgresPutsNulls(new, ids 2700–2708) orders a range column and a multirange column holding every shape by each bound, in both directions. It asserts the documented placement: memory's order with the null-bound rows moved to the end ascending and the front descending. It also asserts that theBound() != nullkey gives memory's order exactly.bound-declared-null-only-for-a-null-argument.patch(LowerBound() and UpperBound() in a query: == null becomes WHERE FALSE and ?? max loses its COALESCE, because lower() and upper() are declared NULL only for a NULL argument #349 reverted, which no seed held yet):dotnet run tools/oracles.cs seeds bound-declaredreports it caught byExecutedQueryTests, 2 of 17 failing. Applied by hand, the new test fails on the keyed order, becauseLowerBound() != nullfolds toTRUEand the order falls back to the database's.postgres:16-alpine: all eight projects pass (core 1399, NodaTime 239, EF 297, EF NodaTime 83, ASP.NET Core 92, conventions 409, integration 289, infinity-disabled 4).🤖 Generated with Claude Code