Error when searching for ID and drafts enabled

Open
#15,648 2 comments 1 reaction 1 assignee View on GitHub

@PatrikKozak is already working on this.

Since Feb 17, 2026.

Assessment

This issue has not been assessed yet.

Description

Bug db: postgres
Describe the Bug

Using the PostgresSql adapter, the list view crashes on my collection:

  • a collection with versions and drafts enabled
  • listSearchableFields with ID and another field e.g. listSearchableFields: ['id', 'title']
  • search for a non-numeric value

The error that is given is
error: invalid input syntax for type integer: "NaN"

The part of the query that causes the error:
("_posts_v"."parent_id" = $6 or "_posts_v"."version_title" ilike $7) where the 6th parameter is "NaN".

Link to the code that reproduces this issue

https://github.com/snakemastr/payload_reproduction_versions_id

Reproduction Steps
  • Create a collection
  • Add a text field 'title'
  • Enable versions with drafts
  • Set admin.listSearchableFields = ['id', 'title']
  • Add a document to the collection
  • try to search the document on title with a non-numeric value
Which area(s) are affected?

db: postgres

Environment Info
Payload: 3.68.3
Node: 22.19.0
Next.js: 15.5.9
Dominant language
TypeScript
Stars
44.8k
Forks
4.2k
Avg merge
2d 21h
Merged PRs (30d)
53

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.

More from payloadcms/payload

All issues in payloadcms/payload

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.