Repository navigation
fix: a predicate over a null range, range set or value set is false (10.x, port of #355, #356 and #350's predicate half) - #373
Merged
Conversation
RangeSet.From, the collection-expression builder RangeSet.Create, and through
them Union and Except called on a null range, built a set whose one element was
null: Count 1, IsEmpty() false, Equals(Empty) false, and the first Contains threw
NullReferenceException. With two or more inputs From threw while sorting, and
next to (,) the null was ignored, because the loop returned at the first infinity.
Both normalize loops and the single-element fast path now throw
ArgumentException ("A range set cannot contain a null range.", ranges) for a null
anywhere in the input, reading every input after an infinity too. That is the
value sets' rule: a null element refused with ArgumentException, never dropped,
because a null range is not an empty one.
RangeSetNullContractTests (conventions, registered as an exception oracle beside
ValueSetNullContractTests) discovers every range type of both libraries and puts
the null first, after a bounded, the empty and the infinite range, through both
From overloads and Create, plus Union and Except on a null range. Its seed
rangeset-stores-a-null-range.patch is caught. Claim M18 quotes the new
docs/ranges.md sentence. #350's Union(Infinite).Contains(v) candidate reports
fixed, since memory now throws for it, and is removed.
Found-By: CA
Defect-Class: CAN
Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit f4f05dd)
…355, #350) Rule (c) from #350, the predicate half: a Boolean predicate with a null range, range set or value set on either side is false, and its negation true, in memory and in SQL, as EF Core answers for its own types. Memory: null guards on every RangeExtensions and RangeSet predicate that did not already answer false. Contains(Empty), IsContainedBy((,)) and (,).Contains(null) returned true; Contains(T), a null RangeSet operand and RangeSet's own predicates with a null operand threw. Value set predicates keep throwing for a null set. SQL: both method-call translators wrap every bool translation as x IS NOT NULL AND <predicate> for each range, multirange or value set operand. EF Core drops the check for a required column and a non-null parameter and writes x IS NULL OR NOT (...) under a negation, so a negated predicate keeps the NULL row and a projected one reads false. CompareTo never reaches the translator, and equality is EF Core's own. RangeNullPredicateContractTests (new oracle) and ExecutedQueryTests.EveryPredicate_OverANullableColumn_IsFalseForTheNullRow discover every predicate; three seeds keep the reverts. #350's seven predicate candidates are removed as fixed. NullOperandTranslationTests pins the SQL; the captured-list pins gain the list element's null check. Claims R49 and E71. Found-By: US Defect-Class: SQL Co-Authored-By: Claude Opus 5.5 <[email protected]> (cherry picked from commit 8bd0048)
This was referenced Oct 24, 2026
CaffeinatedCoder
enabled auto-merge
October 24, 2026 16:42
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 #357
The 10.x port of the predicate half of rule (c) for 10.2.0 (#358):
git cherry-pick -xof #370's commit (f4f05dd, #356) and #371's commit (8bd0048, #355 with #350's predicate half), both merged intomain. Againstrelease/10.xthe closing keyword closes nothing, so #357 is closed by hand after the merge.Problem
10.1.0 has every defect the two
mainPRs fix:RangeSet.Fromstored it, andExceptandUnionon a null range built such a set.truein memory (Contains(Empty),IsContainedBy((,)),(,).Contains(null)), and some threw (Contains(T), a null set operand,RangeSet's own predicates).Change
main:Fromrefuses a null range withArgumentException; the predicates get their null guards; both method-call translators wrap everybooltranslation asx IS NOT NULL AND <predicate>. The commits also bringRangeSetNullContractTestsandRangeNullPredicateContractTestsas oracles,EveryPredicate_OverANullableColumn_IsFalseForTheNullRow,NullOperandTranslationTests, claims M18, R49 and E71, the four seeds, and the refreshedrange-against-set-reads-first-element-for-upper-bound.patch.ArgumentNullExceptionfromIntersect,Gap,Merge,Union,Except). It changes signatures' behaviour loudly, so it is 11.0.0 only.docs/ranges.mdon this branch says so:UnionandExceptthrowArgumentException(throughFrom), andIntersect,GapandMergereturn a value or throw depending on the operand, so check fornullfirst. The four value-producing A null range answers some extensions in memory and throws on others, and the answers it gives disagree with PostgreSQL on a NULL column #350 candidates stay registered.main's### Breakinglines become### Changed answersrows under[10.2.0], each linking 10.x: a predicate over a null range, RangeSet or value set is false in memory and in SQL (port of the predicate half of #350, #355 and #356) #357 anddocs/migration.md#changed-answers-in-1020. TwoRanges:rows go in the root and core changelogs, and theEF Core:row in the root, EF Core and EF Core NodaTime ones, in area order.docs/migration.md: the subsections### Keep null out of a range setand### Check predicates over a null range or a NULL columnsit under## Changed answers in 10.2.0, with "Before 10.2.0". The 10.x intro is kept.EmptyCollectionSql.FromNoRows(…)per EF Core version. Each element predicate, literal or passed to the helper, gainsw."Value" IS NOT NULL AND, as onmain.test/oracles/candidates.json: 15 → 8 after the two picks.Union(Infinite).Contains(v)and the seven predicate candidates are removed; four Document (,max] at the discrete domain boundary: PostgreSQL raises integer out of range #132 and four A null range answers some extensions in memory and throws on others, and the answers it gives disagree with PostgreSQL on a NULL column #350 remain.Tests
Local, SDK 10.0.402, Docker:
postgres:16-alpine: all eight projects pass (core 1399, NodaTime 239, EF 309, EF NodaTime 91, ASP.NET Core 92, conventions 408, integration 284, infinity-disabled 4).-p:EfFloat=10.0.13 -p:NpgsqlEfFloat=10.0.3, versions confirmed indeps.json): translation 309/309 and integration 284/284. The captured-list pins hold on both EF shapes.ExecutedQueryTestsonpostgres:18-alpine: 16/16.dotnet run tools/oracles.cs seedson this branch, for the four new seeds (the reverts of this port) and every seed that patchesRangeSet.cs,RangeExtensions.csor either method-call translator. All apply and are caught (run below).🤖 Generated with Claude Code