Skip to content

Date field timezone: true writes empty string to _tz enum column in Postgres, causing invalid input value for enum ...: "" #16283

@truuman

Description

@truuman

Describe the Bug

When using Payload with Postgres (Drizzle adapter) and a date field configured with timezone: true, Payload auto-creates a hidden select field ${fieldName}_tz (e.g. startDate_tz). If no timezone is selected / no default timezone is configured, the request payload ends up writing "" (empty string) to the DB column.

The Postgres adapter generates the _tz column as a Postgres enum (from supported timezones). Postgres enums cannot accept "" unless it’s explicitly in the enum, so saving/updating the document fails with:

invalid input value for enum enum_<collection>_<field>_tz: ""

Timezones are intended to be optional, so “unset” should serialize to null / undefined (or omit the field), not "".

Saving a document with no timezone selected should store NULL (or omit) for startDate_tz, since timezone is optional.

https://github.com/payloadcms/payload/blob/main/packages/payload/src/fields/config/sanitize.ts#L545

baseTimezoneField returns a hidden select and when there is no default timezone, the value serializes as an empty string instead of null / undefined.

Link to the code that reproduces this issue

sorry I don't have the time for that but blocking users to report traceable bugs seems counter-productive

Reproduction Steps

  1. Configure Payload with Postgres (Drizzle) adapter.
  2. Create a collection with a date field:
{
  name: 'startDate',
  type: 'date',
  timezone: true,
}
  1. Ensure there is no defaultTimezone set globally (config.admin.timezones.defaultTimezone) and no timezone.defaultTimezone on the field.
  2. Create or update a document setting startDate, leaving timezone unset.
  3. Observe 500 error and Postgres enum error.

Which area(s) are affected?

db: postgres

Environment Info

Binaries:
  Node: 20.20.0
  npm: 11.7.0
  Yarn: N/A
  pnpm: 10.28.0
Relevant Packages:
  payload: 3.80.0
Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Thu Jun  5 18:30:46 UTC 2025
  Available memory (MB): 15676
  Available CPU cores: 12

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions