DEV Community

Cover image for Omitted Is Not Empty: Modeling Nullable Partial Updates
LkSvn
LkSvn

Posted on

Omitted Is Not Empty: Modeling Nullable Partial Updates

While adding Job Opportunity editing to my Candidate Tracker, one optional description produced three different behaviors:

  1. omit the property to preserve the stored value;
  2. provide a string to replace it;
  3. provide null to clear it.

The first version mixed undefined and null across the domain, Prisma adapter, application service, and form action. That made clearing a value ambiguous.

The final convention uses string | null for persisted domain entities and optional properties for partial update commands. PostgreSQL NULL, Prisma null, and the domain now use the same absence representation. At the update boundary, omission still means “do not change.”

The broader lesson is that update types describe commands and state transitions. They should distinguish every behavior the application needs instead of merely reusing an entity shape without considering omission.

Top comments (0)