Skip to content

feat: range-receiver overloads with a RangeSet operand, and RangeSet.IsContainedBy - #187

Merged
CaffeinatedCoder merged 2 commits into
mainfrom
feat/range-set-operand
Oct 18, 2026
Merged

CaffeinatedCoder merged 2 commits into
mainfrom
feat/range-set-operand

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #92

Problem

PostgreSQL's range × multirange operators come in two halves. The multirange-receiver half was complete on RangeSet. The range-receiver half had no member, so a range could not take a RangeSet operand, and RangeSet had no IsContainedBy. Three operators could not be reached at all, even through a converse: anyrange @> anymultirange, anyrange &< anymultirange and anyrange &> anymultirange. The last two are not converses of the set-receiver forms, because a &< m compares upper bounds and m &> a compares lower bounds. Five postgres-surface.json rows were open under this issue.

Change

  • RangeExtensions (the extension<TRange, T>(TRange) block): Contains, IsContainedBy, Overlaps, IsStrictlyLeftOf, IsStrictlyRightOf, DoesNotExtendRightOf, DoesNotExtendLeftOf and IsAdjacentTo taking RangeSet<TRange, T>. Each reads the set's outer element it compares: the first for << and &>, the last for >> and &<, both for @> (a range has no gaps). It then hands the pair to the existing range-against-range predicate. Nothing switches on the receiver's shape, so the AGENTS.md dispatch rule holds without a new switch. An empty set answers as PostgreSQL does.
  • RangeSet: IsContainedBy(IRange<T>) and IsContainedBy(RangeSet<TRange, T>) (<@).
  • EF Core (ValueRangesMethodCallTranslator): the eight overloads become the operator with the range on the left (b."Period" &< b."Blocked"), with no multirange lift. RangeSet.IsContainedBy becomes <@. The static method lookups used Single by name, so the range-operand and set-operand overloads are now told apart explicitly (TakesSet).
  • NodaTime: the members are generic, so the four NodaTime range types get them. They are tested in core and in the EF NodaTime translation tests.
  • Docs: docs/ranges.md#compare-a-range-with-a-set (new). The full multirange operator matrix wording now covers both sides. docs/efcore.md gets the operator note and the What runs where row.
  • Catalogues: claims M13–M16 and E46. The five surface rows are filled, and the five rows that pointed at a converse (anyrange << anymultirange → RangeSet.IsStrictlyRightOf, …) now name the direct member.
  • Changelogs: ### Added under 10.0.0 in the root, core, NodaTime and EF Core changelogs.

Tests

  • ShapeMatrixParityTests (integration): Int32Range and DateRange, every range shape against every set built from up to two shapes, through all eight operators with the range on the left, plus RangeSet.IsContainedBy(range).
  • ContinuousMultirangeParityTests (integration): <@ added to the predicate list, so set ⋄ set and set ⋄ range now cover RangeSet.IsContainedBy. A new sweep checks every range operand against every subset of the six fragments with the range on the left.
  • Seed range-against-set-reads-first-element-for-upper-bound.patch makes &< read the set's first element. dotnet run tools/oracles.cs seeds range-against-set reports CAUGHT for both oracles.
  • RangeSetOperandTests (core) covers the worked examples and the empty cases. NodaTimeRangeSetTests covers the NodaTime types. QueryTranslationTests and NodaQueryTranslationTests cover the translations for columns and parameters.
  • The unit, NodaTime, EF, EF NodaTime, conventions and ASP.NET Core tests and the full integration suite (234) pass locally.

This PR is independent of #183 (#39). Both add lines to CHANGELOG.md and test/oracles/*.json, so merging the second may need those conflicts resolved by keeping both sides.

🤖 Generated with Claude Code

…IsContainedBy

The other half of PostgreSQL's range x multirange operator matrix. On the TRange extension
block: Contains, IsContainedBy, Overlaps, IsStrictlyLeftOf, IsStrictlyRightOf,
DoesNotExtendRightOf, DoesNotExtendLeftOf and IsAdjacentTo taking a RangeSet. On RangeSet:
IsContainedBy(IRange<T>) and IsContainedBy(RangeSet). Each reads the set's outer element it
compares (first for <<, &>; last for >>, &<; both for @>) and hands the pair to the existing
range-against-range predicate, so nothing switches on the receiver's shape.

EF Core translates them as the operator with the range on the left, with no multirange lift;
the translator's method lookups now filter the RangeSet overloads explicitly.

ShapeMatrixParityTests (Int32Range, DateRange) and ContinuousMultirangeParityTests
(nummultirange) ask PostgreSQL for every range against every set, and the multirange sweeps
now include <@. Seeded with range-against-set-reads-first-element-for-upper-bound.patch.

Closes #92

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@CaffeinatedCoder CaffeinatedCoder added this to the 10.0.0 milestone Oct 18, 2026
@CaffeinatedCoder CaffeinatedCoder added enhancement New feature or request area/ranges Range unions, variants and the shape engines area/range-set RangeSet and multirange algebra package/nodatime Affects CodoMetis.ValueRanges.NodaTime package/efcore Affects CodoMetis.ValueRanges.EFCore.PostgreSQL package/core Affects CodoMetis.ValueRanges labels Oct 18, 2026
# Conflicts:
#	CHANGELOG.md
#	src/CodoMetis.ValueRanges.EFCore.PostgreSQL/CHANGELOG.md
#	src/CodoMetis.ValueRanges.NodaTime/CHANGELOG.md
#	src/CodoMetis.ValueRanges/CHANGELOG.md
#	test/CodoMetis.ValueRanges.EFCore.PostgreSQL.Tests/QueryTranslationTests.cs
#	test/oracles/claims.json
@CaffeinatedCoder
CaffeinatedCoder merged commit d073eb6 into main Oct 18, 2026
@CaffeinatedCoder
CaffeinatedCoder deleted the feat/range-set-operand branch October 18, 2026 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/range-set RangeSet and multirange algebra area/ranges Range unions, variants and the shape engines enhancement New feature or request package/core Affects CodoMetis.ValueRanges package/efcore Affects CodoMetis.ValueRanges.EFCore.PostgreSQL package/nodatime Affects CodoMetis.ValueRanges.NodaTime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Range-receiver overloads with a RangeSet operand, and RangeSet.IsContainedBy (the other half of the range × multirange operator matrix)

1 participant