payloadcms / payloadcms/payload

(Postgres) Point field breaks version updates (v3)

Open
#16,729 3 comments 0 reactions 1 assignee View on GitHub

@r1tsuu is already working on this.

Since Jul 8, 2026.

db: postgres stale v3
Dominant language
TypeScript
Stars
44.8k
Forks
4.2k
Avg merge
2d 21h
Merged PRs (30d)
53

Description

Describe the Bug

When using @payloadcms/db-postgres with a collection that has both a point field and versions enabled, updating a document fails while Payload tries to insert the version row into _v table

The main collection update appears to receive the point value as valid GeoJSON:

{
  type: 'Point',
  coordinates: [11, 1],
}

But when Payload saves the version row into the collection’s _v table, the point value is passed as the normalized Payload point array:

[11, 1]

The insert action was done by calling ST_GeomFromGeoJSON() which expects a valid GeoJSON but gets an array here and would fail with unknown GeoJSON type.

The whole update & creation operation seems to be wrapped in a transaction, thus keeping everything untouched.

Link to the code that reproduces this issue

https://github.com/kunKun-tx/payload-point-ver-test

Reproduction Steps

Steps to recreate issue

  1. Create a Payload v3 project using @payloadcms/db-postgres.
  2. Use PostgreSQL with PostGIS enabled.
  3. Update an existing collection with a new point field
    {
      name: 'coordinates',
      type: 'point',
      required: true,
      index: true,
    }
    
  4. Enable versioning
    versions: {
      maxPerDoc: 30,
      drafts: true,
    }
    
  5. Create a new collection item and save
  6. Update the recently created item, any field will do.
  7. The main update starts, but saving the version row fails with unknown GeoJSON type

Expected Behavior

The original item shall be updated and a new record in the _v table shall be created.

Actual Behavior

The admin UI displays a red error message, Something went wrong. Payload fails while inserting into the version table because ST_GeomFromGeoJSON receives [lng, lat] instead of a GeoJSON object.

Typical error message

ERROR: Failed query

Query:

insert into "_media_v" (
  "id",
  "parent_id",
  "version_alt",
  "version_point",
  "version_updated_at",
  "version_created_at",
  "version__status",
  "version_url",
  "version_thumbnail_u_r_l",
  "version_filename",
  "version_mime_type",
  "version_filesize",
  "version_width",
  "version_height",
  "version_focal_x",
  "version_focal_y",
  "created_at",
  "updated_at",
  "latest"
)
values (
  default,
  $1,
  $2,
  ST_GeomFromGeoJSON($3),
  $4,
  $5,
  $6,
  $7,
  $8,
  $9,
  $10,
  $11,
  $12,
  $13,
  $14,
  $15,
  $16,
  $17,
  $18
)
returning
  "id",
  "parent_id",
  "version_alt",
  "version_point",
  "version_updated_at",
  "version_created_at",
  "version__status",
  "version_url",
  "version_thumbnail_u_r_l",
  "version_filename",
  "version_mime_type",
  "version_filesize",
  "version_width",
  "version_height",
  "version_focal_x",
  "version_focal_y",
  "created_at",
  "updated_at",
  "latest";

Params:

$1   <document_id>
$2   <redacted>
$3   [12,22]
$4   <timestamp>
$5   <timestamp>
$6   published
$7   <redacted_media_url>
$8   null
$9   <redacted_filename>
$10  image/png
$11  15225
$12  186
$13  186
$14  50
$15  50
$16  <timestamp>
$17  <timestamp>
$18  true

Error:

DrizzleQueryError: unknown GeoJSON type

Stack:

Error: Failed query: insert into "_media_v" (
  "id",
  "parent_id",
  "version_alt",
  "version_point",
  "version_updated_at",
  "version_created_at",
  "version__status",
  "version_url",
  "version_thumbnail_u_r_l",
  "version_filename",
  "version_mime_type",
  "version_filesize",
  "version_width",
  "version_height",
  "version_focal_x",
  "version_focal_y",
  "created_at",
  "updated_at",
  "latest"
)
values (
  default,
  $1,
  $2,
  ST_GeomFromGeoJSON($3),
  $4,
  $5,
  $6,
  $7,
  $8,
  $9,
  $10,
  $11,
  $12,
  $13,
  $14,
  $15,
  $16,
  $17,
  $18
)
returning
  "id",
  "parent_id",
  "version_alt",
  "version_point",
  "version_updated_at",
  "version_created_at",
  "version__status",
  "version_url",
  "version_thumbnail_u_r_l",
  "version_filename",
  "version_mime_type",
  "version_filesize",
  "version_width",
  "version_height",
  "version_focal_x",
  "version_focal_y",
  "created_at",
  "updated_at",
  "latest";

params:
  <document_id>,
  <redacted>,
  [12,22],
  <timestamp>,
  <timestamp>,
  published,
  <redacted_media_url>,
  null,
  <redacted_filename>,
  image/png,
  15225,
  186,
  186,
  50,
  50,
  <timestamp>,
  <timestamp>,
  true
Which area(s) are affected?

db: postgres

Environment Info
Binaries:
  Node: 23.11.0
  npm: 11.1.0
  Yarn: 1.22.17
  pnpm: 10.28.1
Relevant Packages:
  payload: 3.84.1
  next: 16.2.6
  @payloadcms/db-postgres: 3.84.1
  @payloadcms/drizzle: 3.84.1
  @payloadcms/graphql: 3.84.1
  @payloadcms/next/utilities: 3.84.1
  @payloadcms/richtext-lexical: 3.84.1
  @payloadcms/translations: 3.84.1
  @payloadcms/ui/shared: 3.84.1
  react: 19.2.6
  react-dom: 19.2.6
Operating System:
  Platform: linux
  Arch: x64
  Version: #111~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue Apr 14 17:13:45 UTC 
  Available memory (MB): 17079
  Available CPU cores: 8

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.