You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Null value set in ExecuteUpdate on a JSON column is refused with the to_jsonb message #57
area/value-setsValue set families and wrapper aritiesbugSomething isn't workingfound-by/oracleFound by the generated-oracle machinery (claims × API surfaces)package/efcoreAffects CodoMetis.ValueRanges.EFCore.PostgreSQLseverity/lowCosmetic, message or documentation-level difference
ExecuteUpdate that sets a value set inside a JSON column to null is refused by ValueSetSqlGuard with InvalidOperationException, which is right. But the message describes the other case the guard refuses: to_jsonb writing a JSON array where the document holds the literal. For a null value that's misleading. It should say what is refused and what to write instead.
The failure is loud and the fix only changes a message. Found during the probing round (#52), where it came up while checking E27.
Measured against PostgreSQL 17 (Testcontainers), with the guard's throw disabled to see what would be sent. "Doc" is a required ToJson() complex property, so the column is NOT NULL.
Setter
SQL sent
PostgreSQL
Row afterwards
constant (StringSet?)null
jsonb_set(j."Doc", '{MaybeTags}', to_jsonb(NULL))
42804 could not determine polymorphic type
unchanged
null parameter
same SQL. The provider inlines a null parameter as NULL before the guard runs
42804
unchanged
may be null: r => r.Id > 0 ? null : some
jsonb_set(…, to_jsonb(CASE WHEN … THEN NULL ELSE @some END))
23502 null value in column "Doc"
unchanged
non-null parameter (for comparison)
jsonb_set(…, to_jsonb(@p))
succeeds
["p"], row no longer loads
In plain SQL, jsonb_set(doc, path, NULL) and jsonb_set(doc, path, to_jsonb(NULL::text[])) both return NULL. jsonb_set is strict, so a typed NULL replaces the whole document. On a required column that fails with 23502. On an optional one it would erase the document. So the refusal is right in every case. Only the message was wrong.
Workarounds, both verified live: load the entity, set the property to null and call SaveChanges (it writes "MaybeTags": null, and the row loads null). Or SetProperty(r => r.Doc, doc) with a document that holds the null. Both rows then match r.Doc.MaybeTags == null on the server.
The fix:
A definitely-null value (constant or parameter) gets its own message: what is refused, the whole-document NULL, and the two workarounds.
A value that may be null (a conditional with a NULL branch, or a nullable column) keeps the to_jsonb message and adds the whole-document NULL.
A non-null value keeps the original message.
The set of refused setters is unchanged. A null write could be translated correctly ('null'::jsonb gives {"t": null}): #72.
Oracle check (main at 3ecfa10):no oracle on main catches this (pending, expected miss). I reverse-applied #74's src/ diff on 3ecfa10 and ran every class in oracles.json, including UnionCanonicalityTests. All of them stayed green. The fix's own tests did fail (ExecuteUpdateJsonTests 2, ExecuteUpdateGuardTests 4), which shows the revert put the defect back. Why no oracle can catch it: the refusal itself was right, and only its wording was wrong. Error wording has no independent reference, so it is outside what the machinery checks (docs/oracles.md#what-it-does-not-see). Claim E27 is held only by those two regression tests. Neither route B step varies it.
area/value-setsValue set families and wrapper aritiesbugSomething isn't workingfound-by/oracleFound by the generated-oracle machinery (claims × API surfaces)package/efcoreAffects CodoMetis.ValueRanges.EFCore.PostgreSQLseverity/lowCosmetic, message or documentation-level difference
Activity
CaffeinatedCoder commentedon Oct 17, 2026
Measured against PostgreSQL 17 (Testcontainers), with the guard's throw disabled to see what would be sent.
"Doc"is a requiredToJson()complex property, so the column isNOT NULL.(StringSet?)nulljsonb_set(j."Doc", '{MaybeTags}', to_jsonb(NULL))42804could not determine polymorphic typeNULLbefore the guard runs42804r => r.Id > 0 ? null : somejsonb_set(…, to_jsonb(CASE WHEN … THEN NULL ELSE @some END))23502null value in column "Doc"jsonb_set(…, to_jsonb(@p))["p"], row no longer loadsIn plain SQL,
jsonb_set(doc, path, NULL)andjsonb_set(doc, path, to_jsonb(NULL::text[]))both returnNULL.jsonb_setis strict, so a typed NULL replaces the whole document. On a required column that fails with23502. On an optional one it would erase the document. So the refusal is right in every case. Only the message was wrong.Workarounds, both verified live: load the entity, set the property to
nulland callSaveChanges(it writes"MaybeTags": null, and the row loadsnull). OrSetProperty(r => r.Doc, doc)with a document that holds the null. Both rows then matchr.Doc.MaybeTags == nullon the server.The fix:
to_jsonbmessage and adds the whole-document NULL.The set of refused setters is unchanged. A null write could be translated correctly (
'null'::jsonbgives{"t": null}): #72.fix: give a null value set in ExecuteUpdate on a JSON column its own …
CaffeinatedCoder commentedon Oct 17, 2026
Oracle check (main at 3ecfa10): no oracle on main catches this (pending, expected miss). I reverse-applied #74's
src/diff on 3ecfa10 and ran every class inoracles.json, includingUnionCanonicalityTests. All of them stayed green. The fix's own tests did fail (ExecuteUpdateJsonTests2,ExecuteUpdateGuardTests4), which shows the revert put the defect back.Why no oracle can catch it: the refusal itself was right, and only its wording was wrong. Error wording has no independent reference, so it is outside what the machinery checks (
docs/oracles.md#what-it-does-not-see). Claim E27 is held only by those two regression tests. Neither route B step varies it.