Skip to content

A NULL range column now matches CompareTo(null) > 0 in a query; Comparer treats null vs null as equal #261

Closed

Description

@CaffeinatedCoder

Problem

Since #227's rewrite (ValueRangesQueryExpressionInterceptor.cs:230), rows whose nullable range or multirange column is NULL match r.Maybe.CompareTo(none) > 0 when none is null: the server returned 7 of 7. Before #227 they were excluded (NULL > NULL). In memory the call would throw a NullReferenceException on the null receiver, and Comparer<T>.Default.Compare(null, null) is 0, not positive. Found live by the final pre-release analysis on add665c (pass A).

Decision (maintainer, 2026-10-19)

A null receiver against a null operand compares equal, as Comparer<T>.Default does. Rows with a NULL column and a null operand match == 0, >= 0 and <= 0, and not > 0, < 0 or != 0. A NULL column against a non-null operand compares lower (null first), consistent with Comparer<T>.Default and the documented "null sorts first" rule. Work out the ±1 forms of #256 under the same rule.

Done when

RangeOrderParityTests has a nullable-column case with a null and a non-null operand for every comparison (0 and ±1 forms), and the server agrees with Comparer<T>.Default row for row, live. The docs' null sentence says how a NULL column compares.

Activity

  1. added this to the 10.0.0 milestone on Oct 19, 2026
  2. added
    bugSomething isn't working
    silentAnswers wrongly without throwing — fixes go in the next major, never deferred
    area/rangesRange unions, variants and the shape engines
    package/efcoreAffects CodoMetis.ValueRanges.EFCore.PostgreSQL
    severity/lowCosmetic, message or documentation-level difference
    on Oct 19, 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/rangesRange unions, variants and the shape enginesbugSomething isn't workingpackage/efcoreAffects CodoMetis.ValueRanges.EFCore.PostgreSQLseverity/lowCosmetic, message or documentation-level differencesilentAnswers wrongly without throwing — fixes go in the next major, never deferred

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions