Repository navigation
fix: give a null value set in ExecuteUpdate on a JSON column its own refusal - #74
Merged
CaffeinatedCoder merged 1 commit intoOct 17, 2026
Merged
Conversation
…refusal Setting a value set inside a ToJson() column to null with ExecuteUpdate is still refused, but the message gave the to_jsonb JSON-array reason, which only applies to a value. A null constant or parameter reaches the server as jsonb_set(doc, path, to_jsonb(NULL)): 42804, and where PostgreSQL can type the NULL, jsonb_set returns NULL for the whole document. It now gets its own message naming that and the workarounds (SaveChanges, or the whole JSON property). A value that may be null keeps the to_jsonb message and adds the whole-document NULL. What is refused is unchanged. Closes #57 Found-By: OT Defect-Class: SQL Co-Authored-By: Claude Opus 5.5 <[email protected]>
CaffeinatedCoder
force-pushed
the
claude/null-set-json-update-message-2cef26
branch
from
October 17, 2026 18:08
656ee4d to
9832d96
Compare
CaffeinatedCoder
deleted the
claude/null-set-json-update-message-2cef26
branch
October 17, 2026 18:12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #57
Problem
ExecuteUpdatethat sets a value set inside aToJson()column tonullis refused byValueSetSqlGuard, which is right. But the message gave the non-null reason:to_jsonbwriting a JSON array where the document holds the literal. Anullnever writes an array.Measured against PostgreSQL 17, with the refusal disabled (details in #57):
nulland a null parameter both reach the server asjsonb_set("Doc", '{MaybeTags}', to_jsonb(NULL)), because the provider inlines a null parameter. They fail with42804(untyped NULL).r.Id > 0 ? null : some) is typed.jsonb_setis strict, so it returns NULL for the whole document:23502on this required column, and an erased document on an optional one.So the refusal stays. Only the message changes.
Change
SaveChanges(which writes JSONnull), or set the whole JSON property or a complex property that contains the set.to_jsonbmessage and adds the whole-document NULL.The guard refuses exactly the setters it refused before. Only the
Refusaltext depends on the new checks.Also in this PR:
docs/efcore.mdtable row forExecuteUpdatetonullnames the reason and the workarounds, and claimE27follows it.CHANGELOG.mdand the EF package'sCHANGELOG.md.'null'::jsonbgives{"t": null}) is a separate 9.1.0 enhancement: Translate ExecuteUpdate to null for a value set inside a JSON column #72.Tests
ExecuteUpdateGuardTests(no database): constant null, null parameter, a conditional with a null branch, a nullable column, and a required column. Each asserts which reasons its message names and which it leaves out.ExecuteUpdateJsonTests(live):r.Doc.MaybeTags == nullon the server.ValueSetSqlGuard.csrestored tomain, the 4 new unit tests and 2 new live refusal tests fail on their message assertions.ThrowsExactlystill passes, so the refusal fires either way, and the message is what changed.CI=true dotnet teston the whole solution, integration included: green.🤖 Generated with Claude Code