Skip to content

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

Closed

Description

@CaffeinatedCoder

PostgreSQL's range × multirange operator matrix has two halves. The multirange-receiver half is complete on RangeSet (set.Contains(range), set.Overlaps(range), set.IsAdjacentTo(range), <<, >>, &<, &>). The range-receiver half has no member: a range cannot take a RangeSet operand, and RangeSet has no IsContainedBy at all.

Enumerated from pg_operator on 17.11 and 18.4 (identical): anyrange @> anymultirange, anyrange <@ anymultirange, anyrange && anymultirange, anyrange << anymultirange, anyrange >> anymultirange, anyrange &< anymultirange, anyrange &> anymultirange, anyrange -|- anymultirange, and anymultirange <@ anyrange, anymultirange <@ anymultirange.

Most are reachable through symmetry or a converse today (&&, -|- are symmetric; a << m is m.IsStrictlyRightOf(a); a <@ m is m.Contains(a)). Three are not:

  • anyrange @> anymultirange — range.Contains(set); equally set.IsContainedBy(range), which is missing in both forms (RangeSet.IsContainedBy(IRange<T>), RangeSet.IsContainedBy(RangeSet)).
  • anyrange &< anymultirange and anyrange &> anymultirange — not converses of the set-receiver forms (a &< m is upper(a) <= upper(m); m &> a is lower(m) >= lower(a)).

Proposed API: on the IRange<T> extension block, overloads taking RangeSet<TRange, T> for Contains, IsContainedBy, Overlaps, IsStrictlyLeftOf, IsStrictlyRightOf, DoesNotExtendRightOf, DoesNotExtendLeftOf, IsAdjacentTo; on RangeSet, IsContainedBy(IRange<T>) and IsContainedBy(RangeSet).

Translation: the operator with the range on the left, as PostgreSQL has it (b."Period" @> b."Blocked", b."Period" &< b."Blocked"), no multirange lift needed on the range side.

Done when: every one of the 10 operators above has a member, ShapeMatrixParityTests (or a sibling) asks PostgreSQL for every ordered (range shape, set) pair, and docs/ranges.md no longer says "the full multirange operator matrix" only from the set side.

Found by the PostgreSQL catalogue sweep (pg_operator over anyrange/anymultirange), 2026-10-17.

Activity

  1. added
    enhancement
    area/ranges
    area/range-set
    package/efcore
    package/core
    on Oct 17, 2026
  2. added this to the 10.0.0 milestone on Oct 18, 2026
  3. added
    package/nodatime
    on Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/range-setarea/rangesenhancementpackage/corepackage/efcorepackage/nodatime

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions