fix: findDistinct with polymorphic relationships (#13875)

Fixes `findDistinct` with polymorphic relationships and also fixes a bug
from https://github.com/payloadcms/payload/pull/13840 when
`findDistinct` didn't work properly for `hasMany` relationships in
mongodb if `sort` is the same as `field`

---------

Co-authored-by: Patrik Kozak <35232443+PatrikKozak@users.noreply.github.com>
This commit is contained in:
Sasha
2025-09-22 22:23:17 +03:00
committed by GitHub
parent 82d98ab375
commit e99e054d7c
6 changed files with 254 additions and 7 deletions

View File

@@ -132,6 +132,17 @@ export const getConfig: () => Partial<Config> = () => ({
hasMany: true,
name: 'categories',
},
{
type: 'relationship',
relationTo: ['categories'],
name: 'categoryPoly',
},
{
type: 'relationship',
relationTo: ['categories'],
hasMany: true,
name: 'categoryPolyMany',
},
{
type: 'relationship',
relationTo: 'categories-custom-id',