Skip to content

Error when searching for ID and drafts enabled #15648

@snakemastr

Description

@snakemastr

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions