Omitted and Null Fields in a Partial Update

A partial update can interpret omitted fields as unchanged and explicit null as a deliberate clear when permitted by the schema.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Trace an existing nickname
  2. Check defaults and constraints
  3. Apply a patch to a row whose existing values matter
  4. Check concurrent edits to other fields

Trace an existing nickname

Applying an empty patch to a row with a nickname can preserve it. Supplying nickname null may remove it. JSON null versus absence provides a representation for the distinction.

Check defaults and constraints

A column marked not null cannot be cleared with null in the ordinary write. Report that conflict without changing unrelated fields. See required SQL values.[1]

Apply a patch to a row whose existing values matter

An editor sending only title can leave subtitle untouched. An explicit null subtitle can clear it if the patch contract and database permit absence. Writing both fields indiscriminately can erase data the caller never edited. See null and absent JSON members.

Existing: title A, subtitle B
Patch title C → subtitle stays B
Patch subtitle=null → clears if allowed

Check concurrent edits to other fields

Updating only the intended columns can preserve unrelated changes, but shared version rules can still matter. Test omitted, null and explicit empty text against a populated row.

References

  1. PostgreSQL Global Development Group, Concurrency Control ↩