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

@@ -198,6 +198,16 @@ export interface Post {
title: string;
category?: (string | null) | Category;
categories?: (string | Category)[] | null;
categoryPoly?: {
relationTo: 'categories';
value: string | Category;
} | null;
categoryPolyMany?:
| {
relationTo: 'categories';
value: string | Category;
}[]
| null;
categoryCustomID?: (number | null) | CategoriesCustomId;
localized?: string | null;
text?: string | null;
@@ -827,6 +837,8 @@ export interface PostsSelect<T extends boolean = true> {
title?: T;
category?: T;
categories?: T;
categoryPoly?: T;
categoryPolyMany?: T;
categoryCustomID?: T;
localized?: T;
text?: T;