Skip to content

Npgsql 11 writes JSON setters through jsonb_set_lax: the value set refusal names the column instead of the path, and a reason that no longer applies #289

Closed

Description

@CaffeinatedCoder

Problem

Npgsql EF 11 writes an ExecuteUpdate setter inside a jsonb document as jsonb_set_lax(doc, path, value) on PostgreSQL 16 and later whenever the value may be null, and coalesces to JSON null below 16. ValueSetSqlGuard only knew jsonb_set/json_set, so on EF Core 11 the refusal lost the path ('Doc' instead of 'Doc.MaybeTags'; ExecuteUpdateGuardTests and ExecuteUpdateJsonTests fail). The null half of its message is also wrong there: measured on PostgreSQL 16 with the refusal disabled, a value that may be null (to_jsonb(CASE … THEN NULL ELSE @p END)) now sets the property to JSON null for the null outcome, as SaveChanges does, where jsonb_set returned NULL for the whole document; a null constant or parameter still fails on the server with 42804 (to_jsonb(NULL) is untyped). Only the JSON array is left to refuse.

Change

Match jsonb_set_lax too; drop the "writes NULL as the whole document" reason and the MayBeNull distinction; the null refusal names 42804. docs/efcore.md's JSON-column table says the same. Still refused in every case it was.

Found by the #103 retarget's first test run.

Activity

  1. added this to the 11.0.0 milestone on Oct 19, 2026
  2. added
    bugSomething isn't working
    area/value-setsValue set families and wrapper arities
    package/efcoreAffects CodoMetis.ValueRanges.EFCore.PostgreSQL
    severity/lowCosmetic, message or documentation-level difference
    on Oct 19, 2026
  3. CaffeinatedCoder commented on Oct 19, 2026

    @CaffeinatedCoder
    OwnerAuthor

    The 10.x line has this too, behind a configuration knob. Npgsql EF 10.0.3 carries npgsql/efcore.pg#3855 (the jsonb_set_lax name is in its assembly, and in none of 10.0.0–10.0.2); the translator uses it when the configured PostgreSQL version is 16 or later and the value may be null, and Npgsql EF 10's default assumed version is 14 (NpgsqlOptionsExtension.DefaultPostgresVersion). Measured 2026-10-19 on release/10.x with the test host on EF Core 10.0.13 / Npgsql EF 10.0.3: with UpdateTestContext unchanged all 7 ExecuteUpdateGuardTests pass; with .SetPostgresVersion(16, 0) added, 6 of 7 fail on the path in the message ('Doc' for 'Doc.Tags'), every refusal still firing. Filed as #303 under the 10.0.1 epic (#296), severity/low.

    For #294's record: backported to Npgsql EF 10.0.3, reaches a 10.x consumer only through SetPostgresVersion(16, 0) or higher, which the documented PostgreSQL 16 floor invites.

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/value-setsValue set families and wrapper aritiesbugSomething isn't workingpackage/efcoreAffects CodoMetis.ValueRanges.EFCore.PostgreSQLseverity/lowCosmetic, message or documentation-level difference

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions