Open
Description
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:
- Define a virtual field in your CollectionConfig:
{
name: 'computedValue',
type: 'text',
virtual: 'some.path',
}
-
Add computedValue to the
admin.defaultColumns
array. -
Go to the admin UI and open the list view of the collection.
-
Click on the sort arrow in the computedValue column header.
-
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