Skip to content

Type the plugin's NULL constants in its type mappings instead of matching EF Core's empty-root shape #327

Done

Description

@CaffeinatedCoder

Problem

The fixes for #302 (10.x) and #290 (11 line) type the plugin's NULLs by recognising EF Core's output shapes. EmptyCollectionRewriter matches a table-less SELECT … WHERE FALSE whose projections are all NULL constants, and on 10.x also the older empty VALUES. The root cause is lower down: Npgsql writes a null constant without its type, and PostgreSQL resolves a bare NULL as text against the polymorphic range and array operators (42883).

Matching the shape has two costs:

Found by the 10.1.0 review on 2026-10-19 (as an altitude finding).

Question

Can the plugin's range and set type mappings write a typed null literal themselves (NULL::int4range, NULL::text[])? Then every null constant of the plugin's types would be typed wherever it appears, and the rewriter would reduce to the empty-VALUES case EF Core 10.0.0/10.0.1 needs. To answer it:

Release

Internal; no answer should change. If it is done, on both lines.

Activity

  1. added
    chore
    area/range-set
    area/value-sets
    package/efcore
    on Oct 19, 2026
  2. added
    package/efcore-nodatime
    on Oct 19, 2026
  3. added this to the 11.0.0 milestone on Nov 30, 2026
  4. CaffeinatedCoder commented on Nov 30, 2026

    @CaffeinatedCoder
    OwnerAuthor

    Pre-11.0.0 review (2026-11-30, main @ 7c0e11b): assessment.

    Query/EmptyCollectionRewriter.cs is still the shape matcher, and ValueRangesParameterBasedSqlProcessorFactory still wires it. The question in this issue is still open: does Npgsql's GenerateSqlLiteral(null) reach the plugin's mapping? Nobody has measured it yet.

    Proposal. Spike first, half a day:

    1. Override GenerateNonNullSqlLiteral's null twin, or SqlConstantExpression rendering through the mapping, in one range mapping. Run EmptyCollection* and ExecuteUpdateJsonTests on PG 16 and 18.
    2. If Npgsql writes NULL itself, without asking the mapping, this issue needs an upstream change in efcore.pg, so close it and link the upstream issue.
    3. If the mapping is asked, type NULL::<store type> in ValueRangeTypeMapping and the set mappings. Then shrink the rewriter to the EF Core 10.0.0/10.0.1 empty VALUES case. On main (EF Core 11 floor, main: move the EF Core and Npgsql floors to 11.0.0 #533) the rewriter may be removable altogether.
    4. Re-word the to_jsonb(NULL) refusal message (fix: name the property path when refusing a value set setter written through jsonb_set_lax (10.x) #313).

    Breaking: no, but it changes SQL text wherever a NULL of the plugin's types appears, so every translation test that asserts on NULL moves. Effort: L. It needs the spike and both lines, and the integration suites on floor and newest-patch legs.
    Milestone: 11.0.0, the maintainer's decision of 2026-11-30. Of the three refactorings, this one carries the most risk: run the spike early so a "not possible upstream" result doesn't surface late, and land it after #152's two-line CI matrix if it can.

  5. added
    enhancement
    and removed
    chore
    on Nov 30, 2026
  6. added 2 commits that reference this issue on Nov 30, 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/value-setsenhancementpackage/efcorepackage/efcore-nodatime

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions