Skip to content

Sorting by virtual field ist not prohibited and results in error #12886

Open
@LamaAgent

Description

@LamaAgent

Describe the Bug

When attempting to sort a collection list by a virtual field, the admin UI shows a sort arrow in the column header, but clicking it causes an error. The sorting appears to be allowed, even though virtual fields are not queryable via the database.

Link to the code that reproduces this issue

https://github.com/LamaAgent/payloadcms-reprod.git

Reproduction Steps

Steps to reproduce the behavior:

  1. Define a virtual field in your CollectionConfig:
{
  name: 'computedValue',
  type: 'text',
  virtual: 'some.path',
}
  1. Add computedValue to the admin.defaultColumns array.

  2. Go to the admin UI and open the list view of the collection.

  3. Click on the sort arrow in the computedValue column header.

  4. Observe that the admin UI sends a request like ?sort=computedValue, which leads to an error response.

20250621-1932-31.0302457.mp4

Which area(s) are affected? (Select all that apply)

area: core, db-postgres

Environment Info

Binaries:
  Node: 22.15.0
  npm: N/A
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  payload: 3.40.0
  next: 15.3.0
  @payloadcms/db-postgres: 3.40.0
  @payloadcms/graphql: 3.40.0
  @payloadcms/next/utilities: 3.40.0
  @payloadcms/translations: 3.40.0
  @payloadcms/ui/shared: 3.40.0
  react: 19.1.0
  react-dom: 19.1.0
Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Home
  Available memory (MB): 32691
  Available CPU cores: 16

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: needs-triagePossible bug which hasn't been reproduced yet

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions