Repository navigation
feat: range-receiver overloads with a RangeSet operand, and RangeSet.IsContainedBy - #187
Merged
Merged
Conversation
…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]>
# 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
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 #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 aRangeSetoperand, andRangeSethad noIsContainedBy. Three operators could not be reached at all, even through a converse:anyrange @> anymultirange,anyrange &< anymultirangeandanyrange &> anymultirange. The last two are not converses of the set-receiver forms, becausea &< mcompares upper bounds andm &> acompares lower bounds. Fivepostgres-surface.jsonrows were open under this issue.Change
RangeExtensions(theextension<TRange, T>(TRange)block):Contains,IsContainedBy,Overlaps,IsStrictlyLeftOf,IsStrictlyRightOf,DoesNotExtendRightOf,DoesNotExtendLeftOfandIsAdjacentTotakingRangeSet<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>)andIsContainedBy(RangeSet<TRange, T>)(<@).ValueRangesMethodCallTranslator): the eight overloads become the operator with the range on the left (b."Period" &< b."Blocked"), with no multirange lift.RangeSet.IsContainedBybecomes<@. The static method lookups usedSingleby name, so the range-operand and set-operand overloads are now told apart explicitly (TakesSet).docs/ranges.md#compare-a-range-with-a-set(new). The full multirange operator matrix wording now covers both sides.docs/efcore.mdgets the operator note and the What runs where row.anyrange << anymultirange→RangeSet.IsStrictlyRightOf, …) now name the direct member.### Addedunder 10.0.0 in the root, core, NodaTime and EF Core changelogs.Tests
ShapeMatrixParityTests(integration):Int32RangeandDateRange, every range shape against every set built from up to two shapes, through all eight operators with the range on the left, plusRangeSet.IsContainedBy(range).ContinuousMultirangeParityTests(integration):<@added to the predicate list, so set ⋄ set and set ⋄ range now coverRangeSet.IsContainedBy. A new sweep checks every range operand against every subset of the six fragments with the range on the left.range-against-set-reads-first-element-for-upper-bound.patchmakes&<read the set's first element.dotnet run tools/oracles.cs seeds range-against-setreportsCAUGHTfor both oracles.RangeSetOperandTests(core) covers the worked examples and the empty cases.NodaTimeRangeSetTestscovers the NodaTime types.QueryTranslationTestsandNodaQueryTranslationTestscover the translations for columns and parameters.This PR is independent of #183 (#39). Both add lines to
CHANGELOG.mdandtest/oracles/*.json, so merging the second may need those conflicts resolved by keeping both sides.🤖 Generated with Claude Code