Skip to content

Typed expression indexes: string concatenation with a nullable operand differs from EF Core (COALESCE) #94

Closed

Description

@CaffeinatedCoder

Problem

A typed expression index over string concatenation with a nullable operand renders differently from EF Core's query translation, and with different semantics:

Lambda Package EF Core
x.Code + x.Name (string? Name) ("Code" || "Name") "Code" || COALESCE("Name", '')

C# concatenation treats null as empty; PostgreSQL's || yields NULL. The index serves no EF query over the lambda, and a unique index on it leaves every row with a null Name unchecked (a NULL key).

Fix

Wrap nullable operands of a concatenation in COALESCE(…, ''), using the operand nullability #68 introduces, and pin it against ToQueryString() with the other expressions (#72). Changes the stored template, so the index re-creates once: a minor with a ### Changed answers row.

Found by the 5.5.0 pre-tag analysis (PostgreSQL satellite). Depends on #68.

Activity

  1. added this to the 5.6.0 milestone on Oct 19, 2026
  2. added
    bug
    silent
    severity/medium
    package/postgresql
    area/expression-indexes
    on Oct 19, 2026
  3. modified the milestones: 5.6.0, 5.5.0 on Oct 20, 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/expression-indexesbugpackage/postgresqlseverity/mediumsilent

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions